Skip to content

Commit 1a1c74b

Browse files
andy-shevWolfram Sang
authored andcommitted
i2c: core: Check for error pointer for fwnode
Theoretically it's possible that fwnode is returned by some API, that may return an error pointer (and we have, for example, fwnode_find_reference() which does that). If such an fwnode is supplied to the i2c core APIs the functions will perform unneeded loops and checks. Avoid this by preventively checking for an error pointer and bail out immediately. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
1 parent aa1292d commit 1a1c74b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/i2c/i2c-core-base.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,7 @@ struct i2c_client *i2c_find_device_by_fwnode(struct fwnode_handle *fwnode)
10901090
struct i2c_client *client;
10911091
struct device *dev;
10921092

1093-
if (!fwnode)
1093+
if (IS_ERR_OR_NULL(fwnode))
10941094
return NULL;
10951095

10961096
dev = bus_find_device_by_fwnode(&i2c_bus_type, fwnode);
@@ -1875,7 +1875,7 @@ struct i2c_adapter *i2c_find_adapter_by_fwnode(struct fwnode_handle *fwnode)
18751875
struct i2c_adapter *adapter;
18761876
struct device *dev;
18771877

1878-
if (!fwnode)
1878+
if (IS_ERR_OR_NULL(fwnode))
18791879
return NULL;
18801880

18811881
dev = bus_find_device(&i2c_bus_type, NULL, fwnode,

0 commit comments

Comments
 (0)