Jacob Garber has uploaded this change for review. ( https://review.coreboot.org/c/em100/+/34917 )
Change subject: em100: Remove unused assignment ......................................................................
em100: Remove unused assignment
The 'done' variable is only used along the verification code path, not this one.
Change-Id: Ibcdde9548d5ecd55ebecf7d824cf679a28e2322c Signed-off-by: Jacob Garber jgarber1@ualberta.ca Found-by: Coverity CID 205421 --- M em100.c 1 file changed, 2 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/em100 refs/changes/17/34917/1
diff --git a/em100.c b/em100.c index 64a4ab2..d2199c5 100644 --- a/em100.c +++ b/em100.c @@ -784,7 +784,6 @@ if (filename) { int maxlen = desiredchip ? chip->size : 0x4000000; /* largest size - 64MB */ void *data = malloc(maxlen); - int done; void *readback = NULL;
if (data == NULL) { @@ -831,7 +830,7 @@ printf("FATAL: couldn't allocate memory(size: %x)\n", maxlen); return 1; } - done = read_sdram(&em100, readback, 0, maxlen); + read_sdram(&em100, readback, 0, maxlen); memcpy((unsigned char*)readback + spi_start_address, data, length); write_sdram(&em100, (unsigned char*)readback, 0x00000000, maxlen); free(readback); @@ -840,6 +839,7 @@ }
if (verify) { + int done; readback = malloc(length); if (data == NULL) { printf("FATAL: couldn't allocate memory\n");
Stefan Reinauer has posted comments on this change. ( https://review.coreboot.org/c/em100/+/34917 )
Change subject: em100: Remove unused assignment ......................................................................
Patch Set 1:
Shouldn't we check the return value instead?
Jacob Garber has posted comments on this change. ( https://review.coreboot.org/c/em100/+/34917 )
Change subject: em100: Remove unused assignment ......................................................................
Patch Set 1:
Patch Set 1:
Shouldn't we check the return value instead?
That's a good idea. I don't know what to put in the check though.
Peter Tsung Ho Wu has posted comments on this change. ( https://review.coreboot.org/c/em100/+/34917 )
Change subject: em100: Remove unused assignment ......................................................................
Patch Set 1:
Patch Set 1:
Patch Set 1:
Shouldn't we check the return value instead?
That's a good idea. I don't know what to put in the check though.
Let's assume read_sdram() can go wrong. We can check if it is True and if not, skip the line #834 and #835.
Hello Peter Tsung Ho Wu, Stefan Reinauer, David Hendricks, build bot (Jenkins), Patrick Georgi, Martin Roth,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/em100/+/34917
to look at the new patch set (#2).
Change subject: em100: Add read_sdram() error check ......................................................................
em100: Add read_sdram() error check
Skip the memcpy and write_sdram if the readback fails.
Change-Id: Ibcdde9548d5ecd55ebecf7d824cf679a28e2322c Signed-off-by: Jacob Garber jgarber1@ualberta.ca Found-by: Coverity CID 205421 --- M em100.c 1 file changed, 6 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/em100 refs/changes/17/34917/2
Patrick Georgi has posted comments on this change. ( https://review.coreboot.org/c/em100/+/34917 )
Change subject: em100: Add read_sdram() error check ......................................................................
Patch Set 2: Code-Review+2
Patrick Georgi has submitted this change and it was merged. ( https://review.coreboot.org/c/em100/+/34917 )
Change subject: em100: Add read_sdram() error check ......................................................................
em100: Add read_sdram() error check
Skip the memcpy and write_sdram if the readback fails.
Change-Id: Ibcdde9548d5ecd55ebecf7d824cf679a28e2322c Signed-off-by: Jacob Garber jgarber1@ualberta.ca Found-by: Coverity CID 205421 Reviewed-on: https://review.coreboot.org/c/em100/+/34917 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Patrick Georgi pgeorgi@google.com --- M em100.c 1 file changed, 6 insertions(+), 2 deletions(-)
Approvals: build bot (Jenkins): Verified Patrick Georgi: Looks good to me, approved
diff --git a/em100.c b/em100.c index 64a4ab2..b6b23df 100644 --- a/em100.c +++ b/em100.c @@ -832,8 +832,12 @@ return 1; } done = read_sdram(&em100, readback, 0, maxlen); - memcpy((unsigned char*)readback + spi_start_address, data, length); - write_sdram(&em100, (unsigned char*)readback, 0x00000000, maxlen); + if (done) { + memcpy((unsigned char*)readback + spi_start_address, data, length); + write_sdram(&em100, (unsigned char*)readback, 0x00000000, maxlen); + } else { + printf("Error: sdram readback failed\n"); + } free(readback); } else { write_sdram(&em100, (unsigned char*)data, 0x00000000, length);