Commit 49801251 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

Merge branch 'device-properties'

* 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
parents 5d2a1a92 4bf01181
...@@ -528,13 +528,14 @@ int acpi_dev_prop_read(struct acpi_device *adev, const char *propname, ...@@ -528,13 +528,14 @@ int acpi_dev_prop_read(struct acpi_device *adev, const char *propname,
if (!val) if (!val)
return obj->package.count; return obj->package.count;
else if (nval <= 0)
return -EINVAL;
if (nval > obj->package.count) if (nval > obj->package.count)
return -EOVERFLOW; return -EOVERFLOW;
else if (nval <= 0)
return -EINVAL;
items = obj->package.elements; items = obj->package.elements;
switch (proptype) { switch (proptype) {
case DEV_PROP_U8: case DEV_PROP_U8:
ret = acpi_copy_property_array_u8(items, (u8 *)val, nval); ret = acpi_copy_property_array_u8(items, (u8 *)val, nval);
......
...@@ -27,9 +27,10 @@ ...@@ -27,9 +27,10 @@
*/ */
void device_add_property_set(struct device *dev, struct property_set *pset) void device_add_property_set(struct device *dev, struct property_set *pset)
{ {
if (pset) if (!pset)
pset->fwnode.type = FWNODE_PDATA; return;
pset->fwnode.type = FWNODE_PDATA;
set_secondary_fwnode(dev, &pset->fwnode); set_secondary_fwnode(dev, &pset->fwnode);
} }
EXPORT_SYMBOL_GPL(device_add_property_set); EXPORT_SYMBOL_GPL(device_add_property_set);
...@@ -461,7 +462,8 @@ int fwnode_property_read_string(struct fwnode_handle *fwnode, ...@@ -461,7 +462,8 @@ int fwnode_property_read_string(struct fwnode_handle *fwnode,
return acpi_dev_prop_read(to_acpi_node(fwnode), propname, return acpi_dev_prop_read(to_acpi_node(fwnode), propname,
DEV_PROP_STRING, val, 1); 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); EXPORT_SYMBOL_GPL(fwnode_property_read_string);
......
...@@ -136,7 +136,8 @@ static inline bool is_of_node(struct fwnode_handle *fwnode) ...@@ -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) 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) static inline bool of_have_populated_dt(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment