summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVasant Hegde <hegdevasant@linux.vnet.ibm.com>2019-04-09 17:21:24 +0530
committerStewart Smith <stewart@linux.ibm.com>2019-04-17 15:56:34 +1000
commite0b8541ff8ca6f63c0a8bd65308a6e1c01d4e4ac (patch)
treefa6518441902600c6c72a1be67f9e5f9ebf4d8a7
parenta7855bdd659382468ffc17ad6460c4c67488c2e6 (diff)
downloadblackbird-skiboot-e0b8541ff8ca6f63c0a8bd65308a6e1c01d4e4ac.tar.gz
blackbird-skiboot-e0b8541ff8ca6f63c0a8bd65308a6e1c01d4e4ac.zip
opal-prd: Check malloc return value
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
-rw-r--r--external/opal-prd/opal-prd.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/external/opal-prd/opal-prd.c b/external/opal-prd/opal-prd.c
index 1452a17f..41d13ecf 100644
--- a/external/opal-prd/opal-prd.c
+++ b/external/opal-prd/opal-prd.c
@@ -1017,6 +1017,10 @@ static int open_and_read(const char *path, void **bufp, int *lenp)
}
buf = malloc(statbuf.st_size);
+ if (!buf) {
+ close(fd);
+ return -1;
+ }
for (rc = bytes = 0; bytes < statbuf.st_size; bytes += rc) {
rc = read(fd, buf + bytes, statbuf.st_size - bytes);
OpenPOWER on IntegriCloud