Patrick Georgi has uploaded this change for review. ( https://review.coreboot.org/c/em100/+/35066 )
Change subject: firmware.c: Check pointer returned by malloc ......................................................................
firmware.c: Check pointer returned by malloc
Change-Id: Iecf92a9acc54a4ab0a94867e5db265e1db943d53 Signed-off-by: Patrick Georgi pgeorgi@google.com Found-by: Coverity Scan #220610 --- M firmware.c 1 file changed, 4 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/em100 refs/changes/66/35066/1
diff --git a/firmware.c b/firmware.c index b3abafe..d15eb69 100644 --- a/firmware.c +++ b/firmware.c @@ -191,6 +191,10 @@ fseek(f, 0, SEEK_SET);
fw = malloc(fsize); + if (!fw) { + printf("ERROR: out of memory.\n"); + return 0; + } if (fread(fw, fsize, 1, f) != 1) { perror(filename); fclose(f);
Jacob Garber has posted comments on this change. ( https://review.coreboot.org/c/em100/+/35066 )
Change subject: firmware.c: Check pointer returned by malloc ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/c/em100/+/35066/1/firmware.c File firmware.c:
https://review.coreboot.org/c/em100/+/35066/1/firmware.c@195 PS1, Line 195: printf("ERROR: out of memory.\n"); Maybe fclose(f) before returning.
Hello Jacob Garber, build bot (Jenkins), Martin Roth,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/em100/+/35066
to look at the new patch set (#2).
Change subject: firmware.c: Check pointer returned by malloc ......................................................................
firmware.c: Check pointer returned by malloc
Change-Id: Iecf92a9acc54a4ab0a94867e5db265e1db943d53 Signed-off-by: Patrick Georgi pgeorgi@google.com Found-by: Coverity Scan #220610 --- M firmware.c 1 file changed, 5 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/em100 refs/changes/66/35066/2
Patrick Georgi has posted comments on this change. ( https://review.coreboot.org/c/em100/+/35066 )
Change subject: firmware.c: Check pointer returned by malloc ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/c/em100/+/35066/1/firmware.c File firmware.c:
https://review.coreboot.org/c/em100/+/35066/1/firmware.c@195 PS1, Line 195: printf("ERROR: out of memory.\n");
Maybe fclose(f) before returning.
Done
Jacob Garber has posted comments on this change. ( https://review.coreboot.org/c/em100/+/35066 )
Change subject: firmware.c: Check pointer returned by malloc ......................................................................
Patch Set 2: Code-Review+2
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/em100/+/35066 )
Change subject: firmware.c: Check pointer returned by malloc ......................................................................
Patch Set 2: Code-Review+2
Patrick Georgi has submitted this change and it was merged. ( https://review.coreboot.org/c/em100/+/35066 )
Change subject: firmware.c: Check pointer returned by malloc ......................................................................
firmware.c: Check pointer returned by malloc
Change-Id: Iecf92a9acc54a4ab0a94867e5db265e1db943d53 Signed-off-by: Patrick Georgi pgeorgi@google.com Found-by: Coverity Scan #220610 Reviewed-on: https://review.coreboot.org/c/em100/+/35066 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Jacob Garber jgarber1@ualberta.ca Reviewed-by: Angel Pons th3fanbus@gmail.com --- M firmware.c 1 file changed, 5 insertions(+), 0 deletions(-)
Approvals: build bot (Jenkins): Verified Angel Pons: Looks good to me, approved Jacob Garber: Looks good to me, approved
diff --git a/firmware.c b/firmware.c index b3abafe..f5716d8 100644 --- a/firmware.c +++ b/firmware.c @@ -191,6 +191,11 @@ fseek(f, 0, SEEK_SET);
fw = malloc(fsize); + if (!fw) { + printf("ERROR: out of memory.\n"); + fclose(f); + return 0; + } if (fread(fw, fsize, 1, f) != 1) { perror(filename); fclose(f);