Skip to content

Commit

Permalink
Merge branch 'device-properties'
Browse files Browse the repository at this point in the history
* device-properties:
  device property: check fwnode type in to_of_node()
  device property: attach 'else if' to the proper 'if'
  device property: fallback to pset when gettng one string
  device property: fix potential NULL pointer dereference
  • Loading branch information
Rafael J. Wysocki committed Sep 1, 2015
2 parents 5d2a1a9 + 4bf0118 commit 4980125
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions drivers/acpi/property.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,13 +528,14 @@ int acpi_dev_prop_read(struct acpi_device *adev, const char *propname,

if (!val)
return obj->package.count;
else if (nval <= 0)
return -EINVAL;

if (nval > obj->package.count)
return -EOVERFLOW;
else if (nval <= 0)
return -EINVAL;

items = obj->package.elements;

switch (proptype) {
case DEV_PROP_U8:
ret = acpi_copy_property_array_u8(items, (u8 *)val, nval);
Expand Down
8 changes: 5 additions & 3 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 Expand Up @@ -461,7 +462,8 @@ int fwnode_property_read_string(struct fwnode_handle *fwnode,
return acpi_dev_prop_read(to_acpi_node(fwnode), propname,
DEV_PROP_STRING, val, 1);

return -ENXIO;
return pset_prop_read_array(to_pset(fwnode), propname,
DEV_PROP_STRING, val, 1);
}
EXPORT_SYMBOL_GPL(fwnode_property_read_string);

Expand Down
3 changes: 2 additions & 1 deletion include/linux/of.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ static inline bool is_of_node(struct fwnode_handle *fwnode)

static inline struct device_node *to_of_node(struct fwnode_handle *fwnode)
{
return fwnode ? container_of(fwnode, struct device_node, fwnode) : NULL;
return is_of_node(fwnode) ?
container_of(fwnode, struct device_node, fwnode) : NULL;
}

static inline bool of_have_populated_dt(void)
Expand Down

0 comments on commit 4980125

Please sign in to comment.