Skip to content

Commit

Permalink
device property: fix potential NULL pointer dereference
Browse files Browse the repository at this point in the history
In device_add_property_set() we check pset parameter for a NULL, but few lines
later we do a pointer arithmetic without check that will crash kernel in the
set_secondary_fwnode().

Here we check if pset parameter is NULL and return immediately.

Fixes: 16ba08d (device property: Introduce firmware node type for platform data)
Signed-off-by: Andy Shevchenko <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
  • Loading branch information
andy-shev authored and rafaeljw committed Aug 5, 2015
1 parent 74d3329 commit ecc87ee
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/base/property.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
*/
void device_add_property_set(struct device *dev, struct property_set *pset)
{
if (pset)
pset->fwnode.type = FWNODE_PDATA;
if (!pset)
return;

pset->fwnode.type = FWNODE_PDATA;
set_secondary_fwnode(dev, &pset->fwnode);
}
EXPORT_SYMBOL_GPL(device_add_property_set);
Expand Down

0 comments on commit ecc87ee

Please sign in to comment.