* [PATCH v3 1/3] device property: add spaces to PROPERTY_ENTRY_STRING macro
2015-12-29 11:07 [PATCH v3 0/3] device property: post merge fixes Andy Shevchenko
@ 2015-12-29 11:07 ` Andy Shevchenko
2015-12-29 11:07 ` [PATCH v3 2/3] device property: the secondary fwnode needs to depend on the primary Andy Shevchenko
2015-12-29 11:07 ` [PATCH v3 3/3] device property: avoid allocations of 0 length Andy Shevchenko
2 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2015-12-29 11:07 UTC (permalink / raw)
To: Stephen Rothwell, linux-next, akpm, linux-kernel,
heikki.krogerus, Rafael J . Wysocki, linux-acpi
Cc: Andy Shevchenko
Just a style fix, no functional changes.
To be folded to Andrew's patch [1].
[1] http://comments.gmane.org/gmane.linux.kernel.commits.mm/97592
Or in linux next:
e39ece7 include-linux-propertyh-fix-build-issues-with-gcc-444-fix
40bb8a1 include/linux/property.h: fix build issues with gcc-4.4.4
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
include/linux/property.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/property.h b/include/linux/property.h
index b8c4e42..b51fcd3 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -230,7 +230,7 @@ struct property_entry {
.name = _name_, \
.length = sizeof(_val_), \
.is_string = true, \
- { .value = {.str = _val_} }, \
+ { .value = { .str = _val_ } }, \
}
#define PROPERTY_ENTRY_BOOL(_name_) \
--
2.6.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v3 2/3] device property: the secondary fwnode needs to depend on the primary
2015-12-29 11:07 [PATCH v3 0/3] device property: post merge fixes Andy Shevchenko
2015-12-29 11:07 ` [PATCH v3 1/3] device property: add spaces to PROPERTY_ENTRY_STRING macro Andy Shevchenko
@ 2015-12-29 11:07 ` Andy Shevchenko
2015-12-29 11:07 ` [PATCH v3 3/3] device property: avoid allocations of 0 length Andy Shevchenko
2 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2015-12-29 11:07 UTC (permalink / raw)
To: Stephen Rothwell, linux-next, akpm, linux-kernel,
heikki.krogerus, Rafael J . Wysocki, linux-acpi
Cc: Andy Shevchenko
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
This fixes NULL pointer dereference when the primary fwnode handle
does not exist, for example with PCI devices that do not have ACPI
companion.
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/base/property.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/base/property.c b/drivers/base/property.c
index 0b22c8a..b3429cc 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -218,7 +218,7 @@ bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname)
bool ret;
ret = __fwnode_property_present(fwnode, propname);
- if (ret == false && fwnode->secondary)
+ if (ret == false && fwnode && fwnode->secondary)
ret = __fwnode_property_present(fwnode->secondary, propname);
return ret;
}
@@ -423,7 +423,7 @@ EXPORT_SYMBOL_GPL(device_property_match_string);
int _ret_; \
_ret_ = FWNODE_PROP_READ(_fwnode_, _propname_, _type_, _proptype_, \
_val_, _nval_); \
- if (_ret_ == -EINVAL && _fwnode_->secondary) \
+ if (_ret_ == -EINVAL && _fwnode_ && _fwnode_->secondary) \
_ret_ = FWNODE_PROP_READ(_fwnode_->secondary, _propname_, _type_, \
_proptype_, _val_, _nval_); \
_ret_; \
@@ -593,7 +593,7 @@ int fwnode_property_read_string_array(struct fwnode_handle *fwnode,
int ret;
ret = __fwnode_property_read_string_array(fwnode, propname, val, nval);
- if (ret == -EINVAL && fwnode->secondary)
+ if (ret == -EINVAL && fwnode && fwnode->secondary)
ret = __fwnode_property_read_string_array(fwnode->secondary,
propname, val, nval);
return ret;
@@ -621,7 +621,7 @@ int fwnode_property_read_string(struct fwnode_handle *fwnode,
int ret;
ret = __fwnode_property_read_string(fwnode, propname, val);
- if (ret == -EINVAL && fwnode->secondary)
+ if (ret == -EINVAL && fwnode && fwnode->secondary)
ret = __fwnode_property_read_string(fwnode->secondary,
propname, val);
return ret;
--
2.6.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v3 3/3] device property: avoid allocations of 0 length
2015-12-29 11:07 [PATCH v3 0/3] device property: post merge fixes Andy Shevchenko
2015-12-29 11:07 ` [PATCH v3 1/3] device property: add spaces to PROPERTY_ENTRY_STRING macro Andy Shevchenko
2015-12-29 11:07 ` [PATCH v3 2/3] device property: the secondary fwnode needs to depend on the primary Andy Shevchenko
@ 2015-12-29 11:07 ` Andy Shevchenko
2 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2015-12-29 11:07 UTC (permalink / raw)
To: Stephen Rothwell, linux-next, akpm, linux-kernel,
heikki.krogerus, Rafael J . Wysocki, linux-acpi
Cc: Andy Shevchenko
Arrays can not have zero elements by definition of the unified device
properties. If such property comes from outside we should not allow it to pass.
Otherwise memory allocation on 0 length will return non-NULL value, which we
currently don't check.
Prevent memory allocations of 0 length.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/base/property.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/base/property.c b/drivers/base/property.c
index b3429cc..c359351 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -653,6 +653,9 @@ int fwnode_property_match_string(struct fwnode_handle *fwnode,
if (nval < 0)
return nval;
+ if (nval == 0)
+ return -ENODATA;
+
values = kcalloc(nval, sizeof(*values), GFP_KERNEL);
if (!values)
return -ENOMEM;
@@ -718,6 +721,9 @@ static int pset_copy_entry(struct property_entry *dst,
return -ENOMEM;
if (src->is_array) {
+ if (!src->length)
+ return -ENODATA;
+
if (src->is_string) {
nval = src->length / sizeof(const char *);
dst->pointer.str = kcalloc(nval, sizeof(const char *),
--
2.6.4
^ permalink raw reply related [flat|nested] 4+ messages in thread