MA-14293 [coverity] imx8: Fix double free issue
Fix coverity issue CID 3298992: Double free (USE_AFTER_FREE) double_free: Calling free frees pointer rsrc_data which has already been freed. Check the rsrc_data buffer before free to avoid free NULL pointer. Change-Id: I781e87667a5d3bbe25ec12fbae8e3958d9b29244 Signed-off-by: Luo Ji <ji.luo@nxp.com>
This commit is contained in:
parent
ff76415a1b
commit
4b28b03dbb
|
|
@ -170,7 +170,8 @@ static int do_part_dtb(int argc, char * const argv[])
|
|||
pad_data = kmalloc(pad_size, __GFP_ZERO);
|
||||
if (!pad_data) {
|
||||
debug("No mem\n");
|
||||
free(rsrc_data);
|
||||
if (rsrc_data != NULL)
|
||||
free(rsrc_data);
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
if (fdtdec_get_int_array(fdt, subnode, "pads",
|
||||
|
|
@ -235,8 +236,10 @@ static int do_part_dtb(int argc, char * const argv[])
|
|||
free_data:
|
||||
if (pad_size > 0)
|
||||
free(pad_data);
|
||||
if (rsrc_size > 0)
|
||||
if (rsrc_size > 0) {
|
||||
free(rsrc_data);
|
||||
rsrc_data = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue