device property: fix potential NULL pointer dereference
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Wed, 5 Aug 2015 13:51:11 +0000 (16:51 +0300)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 5 Aug 2015 23:50:21 +0000 (01:50 +0200)
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: 16ba08d5c9ec (device property: Introduce firmware node type for platform data)
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/property.c

index f3f6d167f3f1f015fec8e36ede66b7e8e274338f..37a7bb7b239d06fbe285c553dbe470375e4ad877 100644 (file)
  */
 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);