cmd/gpt: Address error cases during gpt rename more correctly 28/231428/2 accepted/tizen/unified/20200424.141632 submit/tizen/20200423.092248
authorTom Rini <trini@konsulko.com>
Tue, 21 Jan 2020 16:53:38 +0000 (11:53 -0500)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Wed, 22 Apr 2020 09:59:23 +0000 (09:59 +0000)
commit8f09c619f474d3738dd2b34c70533f60cb63f3ac
tree11faced949447ad30725ffbcd10bfab6d854e874
parent9f869b1567a93e519fedd1bd82653215ee00001f
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>
[jh80.chung: cherry picked from mainline commit 5749faa3d683]
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Change-Id: Ifdccec243f89b55363ffd6d18bfee971a42f7bc6
cmd/gpt.c