summaryrefslogtreecommitdiffstats
path: root/drivers/base/swnode.c
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2018-12-22 13:49:39 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2018-12-26 10:48:01 +0100
commit1d8f062ebc972053318c3a0e0470c7e0ddc1ebee (patch)
treec80d228d44f4fc66ca5a597de9ec74daa16e73ba /drivers/base/swnode.c
parentMerge tag 'devprop-4.21-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git... (diff)
downloadlinux-1d8f062ebc972053318c3a0e0470c7e0ddc1ebee.tar.xz
linux-1d8f062ebc972053318c3a0e0470c7e0ddc1ebee.zip
drivers: base: swnode: check if pointer p is NULL before dereferencing it
The pointer p can be potentially NULL as macro to_software_node can return NULL. Add null check on p before dereferencing it to avoid any NULL pointer dereferences. Detected by CoverityScan, CID#1476039 ("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>
Diffstat (limited to 'drivers/base/swnode.c')
-rw-r--r--drivers/base/swnode.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
index 306bb93287af..28b6eb0e5187 100644
--- a/drivers/base/swnode.c
+++ b/drivers/base/swnode.c
@@ -487,7 +487,7 @@ software_node_get_next_child(const struct fwnode_handle *fwnode,
struct software_node *p = to_software_node(fwnode);
struct software_node *c = to_software_node(child);
- if (list_empty(&p->children) ||
+ if (!p || list_empty(&p->children) ||
(c && list_is_last(&c->entry, &p->children)))
return NULL;