summaryrefslogtreecommitdiffstats
path: root/hdata/memory.c
diff options
context:
space:
mode:
authorKamalesh Babulal <kamalesh@linux.vnet.ibm.com>2015-06-23 14:07:36 +0530
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-07-10 14:28:19 +1000
commit550633437ffd0a2629d398493c8bbac51d3aa490 (patch)
treea21d9897e3eee6c71fc2028406d05fb00ac6948d /hdata/memory.c
parentc7271519d4e893a72ebe1a70d9f9f8983a63aa7a (diff)
downloadtalos-skiboot-550633437ffd0a2629d398493c8bbac51d3aa490.tar.gz
talos-skiboot-550633437ffd0a2629d398493c8bbac51d3aa490.zip
find_shared() - Check for return value from dt_find_property
In find_shared(), dt_find_property might return NULL value, so check for validity of the pointer before dereferencing it. Fixes Coverity defect#97846. Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'hdata/memory.c')
-rw-r--r--hdata/memory.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/hdata/memory.c b/hdata/memory.c
index 352dc71a..6bc86959 100644
--- a/hdata/memory.c
+++ b/hdata/memory.c
@@ -69,7 +69,7 @@ static struct dt_node *find_shared(struct dt_node *root, u16 id, u64 start, u64
for (i = dt_first(root); i; i = dt_next(root, i)) {
__be64 reg[2];
- const struct dt_property *shared, *type;
+ const struct dt_property *shared, *type, *region;
type = dt_find_property(i, "device_type");
if (!type || strcmp(type->prop, "memory") != 0)
@@ -79,7 +79,10 @@ static struct dt_node *find_shared(struct dt_node *root, u16 id, u64 start, u64
if (!shared || fdt32_to_cpu(*(u32 *)shared->prop) != id)
continue;
- memcpy(reg, dt_find_property(i, "reg")->prop, sizeof(reg));
+ region = dt_find_property(i, "reg");
+ if (!region)
+ continue;
+ memcpy(reg, region->prop, sizeof(reg));
if (be64_to_cpu(reg[0]) == start && be64_to_cpu(reg[1]) == len)
break;
}
OpenPOWER on IntegriCloud