aboutsummaryrefslogtreecommitdiff
path: root/external
diff options
context:
space:
mode:
authorSuraj Jitindar Singh <sjitindarsingh@gmail.com>2017-12-01 13:41:10 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-12-01 00:54:47 -0600
commit535d86ee98935793c0a03eb0ced6b206ce04825c (patch)
tree728a503f9ec967fa5a4aa6c289c9a9b7cc3c9365 /external
parentdaf9ff43cd0a2845a06b4f6cb209eab0111e13a3 (diff)
downloadskiboot-535d86ee98935793c0a03eb0ced6b206ce04825c.zip
skiboot-535d86ee98935793c0a03eb0ced6b206ce04825c.tar.gz
skiboot-535d86ee98935793c0a03eb0ced6b206ce04825c.tar.bz2
external/pflash: Fix non-zero return code for successful read when size%256 != 0
When performing a read the return value from pflash is non-zero, even for a successful read, when the size being read is not a multiple of 256. This is because do_read_file returns the value from the write system call which is then returned by pflash. When the size is a multiple of 256 we get lucky in that this wraps around back to zero. However for any other value the return code is size % 256. This means even when the operation is successful the return code will seem to reflect an error. Fix this by returning zero if the entire size was read correctly, otherwise return the corresponding error code. Fixes: e1cf130d ("external/pflash: Remove use of exit() and fix memory leaks") Reported-by: Pridhiviraj Paidipeddi <ppaidipe@linux.vnet.ibm.com> Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com> Reviewed-by: Cyril Bur <cyrilbur@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'external')
-rw-r--r--external/pflash/pflash.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c
index 381df24..a5e7bc3 100644
--- a/external/pflash/pflash.c
+++ b/external/pflash/pflash.c
@@ -511,7 +511,7 @@ static int do_read_file(struct blocklevel_device *bl, const char *file,
}
progress_end();
close(fd);
- return rc;
+ return size ? rc : 0;
}
static int enable_4B_addresses(struct blocklevel_device *bl)