diff options
author | Colin Ian King <colin.king@canonical.com> | 2018-12-22 07:43:33 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2018-12-26 04:50:36 -0500 |
commit | f4747b9c68b8864cac32cddc45fdcfdfafb3397c (patch) | |
tree | 3c360edc65d35e30269f0a2a608c234fb7e0acd4 | |
parent | 1d8f062ebc972053318c3a0e0470c7e0ddc1ebee (diff) |
drivers: base: swnode: check if swnode is NULL before dereferencing it
The to_software_mode() macro can potentially return NULL, so also add
a NULL check on swnode before dereferencing it to avoid any NULL
pointer dereferences.
Detected by CoverityScan, CID#1476052 ("Explicit null dereferenced")
Fixes: 59abd83672f7 (drivers: base: Introducing software nodes to the firmware node framework)
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/base/swnode.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c index 28b6eb0e5187..89ad8dee6ad5 100644 --- a/drivers/base/swnode.c +++ b/drivers/base/swnode.c | |||
@@ -477,7 +477,8 @@ software_node_get_parent(const struct fwnode_handle *fwnode) | |||
477 | { | 477 | { |
478 | struct software_node *swnode = to_software_node(fwnode); | 478 | struct software_node *swnode = to_software_node(fwnode); |
479 | 479 | ||
480 | return swnode->parent ? &swnode->parent->fwnode : NULL; | 480 | return swnode ? (swnode->parent ? &swnode->parent->fwnode : NULL) : |
481 | NULL; | ||
481 | } | 482 | } |
482 | 483 | ||
483 | struct fwnode_handle * | 484 | struct fwnode_handle * |