Skip to content

Commit

Permalink
drivers: base: swnode: check if pointer p is NULL before dereferencin…
Browse files Browse the repository at this point in the history
…g 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: 59abd83 (drivers: base: Introducing software nodes to the firmware node framework)
Signed-off-by: Colin Ian King <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
  • Loading branch information
Colin Ian King authored and rafaeljw committed Dec 26, 2018
1 parent d8924c0 commit 1d8f062
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/base/swnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 1d8f062

Please sign in to comment.