Anastasia Klimchuk has submitted this change. ( https://review.coreboot.org/c/flashrom/+/81032?usp=email )
Change subject: serprog: Fix scan-build warning of resource leak ......................................................................
serprog: Fix scan-build warning of resource leak
Warning found by the latest scan-build run:
*** CID 1534883: (RESOURCE_LEAK) /serprog.c: 853 in serprog_init() 847 "by programmer!\n", cs_num8); 848 goto init_err_cleanup_exit; 849 } 850 } 851 bt = serprog_buses_supported; 852 if (sp_docommand(S_CMD_S_BUSTYPE, 1, &bt, 0, NULL))
CID 1534883: (RESOURCE_LEAK) Variable "cs" going out of scope leaks the storage it points to.
853 goto init_err_cleanup_exit; 854 }
Follow up on commit e8c350f55e596aae3ab2bbc210b68389e2301a6c
Change-Id: Id9cf211de3c482f702adebfcfa274a183c83a33f Signed-off-by: Anastasia Klimchuk aklm@flashrom.org Reviewed-on: https://review.coreboot.org/c/flashrom/+/81032 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Alexander Goncharov chat@joursoir.net Reviewed-by: Stefan Reinauer stefan.reinauer@coreboot.org --- M serprog.c 1 file changed, 4 insertions(+), 1 deletion(-)
Approvals: build bot (Jenkins): Verified Alexander Goncharov: Looks good to me, but someone else must approve Stefan Reinauer: Looks good to me, approved
diff --git a/serprog.c b/serprog.c index c2965c5..f738ef3 100644 --- a/serprog.c +++ b/serprog.c @@ -835,9 +835,9 @@ free(cs); goto init_err_cleanup_exit; } - free(cs); if (!sp_check_commandavail(S_CMD_S_SPI_CS)) { msg_perr("Error: Setting SPI chip select is not supported!\n"); + free(cs); goto init_err_cleanup_exit; } msg_pdbg(MSGHEADER "Requested to use chip select %lu.\n", cs_num); @@ -845,9 +845,12 @@ if (sp_docommand(S_CMD_S_SPI_CS, 1, &cs_num8, 0, NULL)) { msg_perr("Error: Chip select %u not supported " "by programmer!\n", cs_num8); + free(cs); goto init_err_cleanup_exit; } } + free(cs); + bt = serprog_buses_supported; if (sp_docommand(S_CMD_S_BUSTYPE, 1, &bt, 0, NULL)) goto init_err_cleanup_exit;