aboutsummaryrefslogtreecommitdiffstats
path: root/usbblaster_spi.c
diff options
context:
space:
mode:
authorThomas Heijligen <thomas.heijligen@secunet.com>2023-02-15 12:12:11 +0100
committerThomas Heijligen <src@posteo.de>2023-02-23 10:27:28 +0000
commit3b16ce087ed3f4bfeed19db9d2115615b55097e5 (patch)
tree251f884e88aaad9e053a7854a2a6d0275ed34eea /usbblaster_spi.c
parentdddf9486854a16c9d736a5286bd6a5913725635e (diff)
downloadflashrom-3b16ce087ed3f4bfeed19db9d2115615b55097e5.tar.gz
flashrom-3b16ce087ed3f4bfeed19db9d2115615b55097e5.tar.bz2
flashrom-3b16ce087ed3f4bfeed19db9d2115615b55097e5.zip
erasure_layout.c: Test erasefn_count before using it to allocate memory
In erasure_layout.c:create_erase_layout() the layout will be allocated based on erasefn_count, But calling calloc with 0 is unspecified behavior. Also it is not freed when erasefn_count is 0. So test first if erasefn_count is 0, and only when not allocate the memory for *layout. Reported by Coverty Scan: *** CID 1505171: Resource leaks (RESOURCE_LEAK) /erasure_layout.c: 105 in create_erase_layout() 98 if(!layout) { 99 msg_gerr("Out of memory!\n"); 100 return -1; 101 } 102 103 if (!erasefn_count) { 104 msg_gerr("No erase functions supported\n"); >>> CID 1505171: Resource leaks (RESOURCE_LEAK) >>> Variable "layout" going out of scope leaks the storage it points to. 105 return 0; 106 } Change-Id: If13b050ac8525fee44d3f3bf74a9c9b6a8d38399 Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/73041 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Diffstat (limited to 'usbblaster_spi.c')
0 files changed, 0 insertions, 0 deletions