cmd/gpt: Address error cases during gpt rename more correctly
authorTom Rini <trini@konsulko.com>
Tue, 21 Jan 2020 16:53:38 +0000 (11:53 -0500)
committerTom Rini <trini@konsulko.com>
Thu, 30 Jan 2020 18:30:35 +0000 (13:30 -0500)
commit5749faa3d6837d6dbaf2119fc3ec49a326690c8f
treed92ce80d2c27e3ded3a7a75133715602cbbbabb1
parente7ab1cb3f0421ad8e8435a8258790e238c623ea2
cmd/gpt: Address error cases during gpt rename more correctly

New analysis by the tool has shown that we have some cases where we
weren't handling the error exit condition correctly.  When we ran into
the ENOMEM case we wouldn't exit the function and thus incorrect things
could happen.  Rework the unwinding such that we don't need a helper
function now and free what we may have allocated.

Fixes: 18030d04d25d ("GPT: fix memory leaks identified by Coverity")
Reported-by: Coverity (CID: 275475, 275476)
Cc: Alison Chaiken <alison@she-devel.com>
Cc: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Cc: Jordy <jordy@simplyhacker.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
cmd/gpt.c