Skip to content

Commit

Permalink
Merge tag 'devprop-4.21-rc1-2' of git://git.kernel.org/pub/scm/linux/…
Browse files Browse the repository at this point in the history
…kernel/git/rafael/linux-pm

Pull device properties framework fixes from Rafael Wysocki:
 "Fix two potential NULL pointer dereferences found by Coverity in the
  software nodes code introduced recently (Colin Ian King)"

* tag 'devprop-4.21-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  drivers: base: swnode: check if swnode is NULL before dereferencing it
  drivers: base: swnode: check if pointer p is NULL before dereferencing it
  • Loading branch information
torvalds committed Jan 3, 2019
2 parents 35ddb06 + f4747b9 commit 01766d2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/base/swnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,8 @@ software_node_get_parent(const struct fwnode_handle *fwnode)
{
struct software_node *swnode = to_software_node(fwnode);

return swnode->parent ? &swnode->parent->fwnode : NULL;
return swnode ? (swnode->parent ? &swnode->parent->fwnode : NULL) :
NULL;
}

struct fwnode_handle *
Expand All @@ -487,7 +488,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 01766d2

Please sign in to comment.