Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1298946 > unrolled thread
| Started by | Andy Shevchenko <andriy.shevchenko@linux.intel.com> |
|---|---|
| First post | 2015-12-29 12:10 +0100 |
| Last post | 2015-12-29 12:10 +0100 |
| Articles | 4 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH v3 0/3] device property: post merge fixes Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-12-29 12:10 +0100
[PATCH v3 3/3] device property: avoid allocations of 0 length Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-12-29 12:10 +0100
[PATCH v3 1/3] device property: add spaces to PROPERTY_ENTRY_STRING macro Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-12-29 12:10 +0100
[PATCH v3 2/3] device property: the secondary fwnode needs to depend on the primary Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-12-29 12:10 +0100
| From | Andy Shevchenko <andriy.shevchenko@linux.intel.com> |
|---|---|
| Date | 2015-12-29 12:10 +0100 |
| Subject | [PATCH v3 0/3] device property: post merge fixes |
| Message-ID | <qL0ka-824-17@gated-at.bofh.it> |
Three fixes to device property API. Patch 1 is a simple style fix to be folded into previous Andrew's patch to allow old gcc to build (see commit message for the details). There is a crash in linux-next BUG: unable to handle kernel NULL pointer dereference at 0000000000000008 IP: [<ffffffff8145e8a6>] fwnode_property_present+0x16/0x30 Check for fwnode pointer before dereference (patch 2). Patch 3 prevents to allocate buffers with 0 length (the result maybe surprising to someone). Changelog v3: - fix typo in Heikki's patch (patch 2) - update commit message for patch 1 to explain what is the fixup for Changelog v2: - added patches 2 and 3 Andy Shevchenko (2): device property: add spaces to PROPERTY_ENTRY_STRING macro device property: avoid allocations of 0 length Heikki Krogerus (1): device property: the secondary fwnode needs to depend on the primary drivers/base/property.c | 14 ++++++++++---- include/linux/property.h | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) -- 2.6.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Andy Shevchenko <andriy.shevchenko@linux.intel.com> |
|---|---|
| Date | 2015-12-29 12:10 +0100 |
| Subject | [PATCH v3 3/3] device property: avoid allocations of 0 length |
| Message-ID | <qL0ka-824-21@gated-at.bofh.it> |
| In reply to | #1298946 |
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Andy Shevchenko <andriy.shevchenko@linux.intel.com> |
|---|---|
| Date | 2015-12-29 12:10 +0100 |
| Subject | [PATCH v3 1/3] device property: add spaces to PROPERTY_ENTRY_STRING macro |
| Message-ID | <qL0kb-824-33@gated-at.bofh.it> |
| In reply to | #1298946 |
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Andy Shevchenko <andriy.shevchenko@linux.intel.com> |
|---|---|
| Date | 2015-12-29 12:10 +0100 |
| Subject | [PATCH v3 2/3] device property: the secondary fwnode needs to depend on the primary |
| Message-ID | <qL0kb-824-43@gated-at.bofh.it> |
| In reply to | #1298946 |
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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web