Skip to content

Commit 011b65b

Browse files
Heikki Krogerus0day robot
authored andcommitted
device property: fwnode->secondary may contain ERR_PTR(-ENODEV)
This fixes BUG that is trickered when fwnode->secondary is not null, but has ERR_PTR(-ENODEV) instead. BUG: unable to handle kernel paging request at ffffffffffffffed IP: [<ffffffff81677b86>] __fwnode_property_read_string+0x26/0x160 PGD 200e067 PUD 2010067 PMD 0 Oops: 0000 [#1] SMP KASAN Modules linked in: dwc3_pci(+) dwc3 CPU: 0 PID: 1138 Comm: modprobe Not tainted 4.5.0-rc5+ torvalds#61 task: ffff88015aaf5b00 ti: ffff88007b958000 task.ti: ffff88007b958000 RIP: 0010:[<ffffffff81677b86>] [<ffffffff81677b86>] __fwnode_property_read_string+0x26/0x160 RSP: 0018:ffff88007b95eff8 EFLAGS: 00010246 RAX: fffffbfffffffffd RBX: ffffffffffffffed RCX: ffff88015999cd37 RDX: dffffc0000000000 RSI: ffffffff81e11bc0 RDI: ffffffffffffffed RBP: ffff88007b95f020 R08: 0000000000000000 R09: 0000000000000000 R10: ffff88007b90f7cf R11: 0000000000000000 R12: ffff88007b95f0a0 R13: 00000000fffffffa R14: ffffffff81e11bc0 R15: ffff880159ea37a0 FS: 00007ff35f46c700(0000) GS:ffff88015b800000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b CR2: ffffffffffffffed CR3: 000000007b8be000 CR4: 00000000001006f0 Stack: ffff88015999cd20 ffffffff81e11bc0 ffff88007b95f0a0 ffff88007b383dd8 ffff880159ea37a0 ffff88007b95f048 ffffffff81677d03 ffff88007b952460 ffffffff81e11bc0 ffff88007b95f0a0 ffff88007b95f070 ffffffff81677d40 Call Trace: [<ffffffff81677d03>] fwnode_property_read_string+0x43/0x50 [<ffffffff81677d40>] device_property_read_string+0x30/0x40 ... Fixes: 362c0b3 (device property: Fallback to secondary fwnode if primary misses the property) Signed-off-by: Heikki Krogerus <[email protected]>
1 parent 3bd418f commit 011b65b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/base/property.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname)
218218
bool ret;
219219

220220
ret = __fwnode_property_present(fwnode, propname);
221-
if (ret == false && fwnode && fwnode->secondary)
221+
if (ret == false && fwnode && !IS_ERR_OR_NULL(fwnode->secondary))
222222
ret = __fwnode_property_present(fwnode->secondary, propname);
223223
return ret;
224224
}
@@ -423,7 +423,7 @@ EXPORT_SYMBOL_GPL(device_property_match_string);
423423
int _ret_; \
424424
_ret_ = FWNODE_PROP_READ(_fwnode_, _propname_, _type_, _proptype_, \
425425
_val_, _nval_); \
426-
if (_ret_ == -EINVAL && _fwnode_ && _fwnode_->secondary) \
426+
if (_ret_ == -EINVAL && _fwnode_ && !IS_ERR_OR_NULL(_fwnode_->secondary)) \
427427
_ret_ = FWNODE_PROP_READ(_fwnode_->secondary, _propname_, _type_, \
428428
_proptype_, _val_, _nval_); \
429429
_ret_; \
@@ -593,7 +593,7 @@ int fwnode_property_read_string_array(struct fwnode_handle *fwnode,
593593
int ret;
594594

595595
ret = __fwnode_property_read_string_array(fwnode, propname, val, nval);
596-
if (ret == -EINVAL && fwnode && fwnode->secondary)
596+
if (ret == -EINVAL && fwnode && !IS_ERR_OR_NULL(fwnode->secondary))
597597
ret = __fwnode_property_read_string_array(fwnode->secondary,
598598
propname, val, nval);
599599
return ret;
@@ -621,7 +621,7 @@ int fwnode_property_read_string(struct fwnode_handle *fwnode,
621621
int ret;
622622

623623
ret = __fwnode_property_read_string(fwnode, propname, val);
624-
if (ret == -EINVAL && fwnode && fwnode->secondary)
624+
if (ret == -EINVAL && fwnode && !IS_ERR_OR_NULL(fwnode->secondary))
625625
ret = __fwnode_property_read_string(fwnode->secondary,
626626
propname, val);
627627
return ret;

0 commit comments

Comments
 (0)