mirror of
https://github.com/torvalds/linux.git
synced 2024-11-26 14:12:06 +00:00
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: 59abd83672
(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>
This commit is contained in:
parent
1d8f062ebc
commit
f4747b9c68
@ -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 *
|
||||
|
Loading…
Reference in New Issue
Block a user