linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] i2c: smbus: Check for parent device before dereference
@ 2022-02-04 15:59 Andy Shevchenko
  2022-02-14 15:09 ` Andy Shevchenko
  2022-02-19 11:46 ` Wolfram Sang
  0 siblings, 2 replies; 3+ messages in thread
From: Andy Shevchenko @ 2022-02-04 15:59 UTC (permalink / raw)
  To: linux-i2c, linux-kernel
  Cc: Wolfram Sang, Andy Shevchenko, syzbot+0591ccf54ee05344e4eb

An I²C adapter might be instantiated without parent. In such case
there is no property can be retrieved. Skip SMBus alert setup when
this happens.

Fixes: a263a84088f6 ("i2c: smbus: Use device_*() functions instead of of_*()")
Reported-by: syzbot+0591ccf54ee05344e4eb@syzkaller.appspotmail.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/i2c-core-smbus.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/i2c-core-smbus.c b/drivers/i2c/i2c-core-smbus.c
index 304c2c8fee68..029f1b7c83bc 100644
--- a/drivers/i2c/i2c-core-smbus.c
+++ b/drivers/i2c/i2c-core-smbus.c
@@ -705,10 +705,14 @@ EXPORT_SYMBOL_GPL(i2c_new_smbus_alert_device);
 #if IS_ENABLED(CONFIG_I2C_SMBUS)
 int i2c_setup_smbus_alert(struct i2c_adapter *adapter)
 {
+	struct device *parent = adapter->dev.parent;
 	int irq;
 
-	irq = device_property_match_string(adapter->dev.parent, "interrupt-names",
-					   "smbus_alert");
+	/* Adapter instantiated without parent, skip the SMBus alert setup */
+	if (!parent)
+		return 0;
+
+	irq = device_property_match_string(parent, "interrupt-names", "smbus_alert");
 	if (irq == -EINVAL || irq == -ENODATA)
 		return 0;
 	else if (irq < 0)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/1] i2c: smbus: Check for parent device before dereference
  2022-02-04 15:59 [PATCH v1 1/1] i2c: smbus: Check for parent device before dereference Andy Shevchenko
@ 2022-02-14 15:09 ` Andy Shevchenko
  2022-02-19 11:46 ` Wolfram Sang
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2022-02-14 15:09 UTC (permalink / raw)
  To: linux-i2c, linux-kernel; +Cc: Wolfram Sang, syzbot+0591ccf54ee05344e4eb

On Fri, Feb 04, 2022 at 05:59:20PM +0200, Andy Shevchenko wrote:
> An I²C adapter might be instantiated without parent. In such case
> there is no property can be retrieved. Skip SMBus alert setup when
> this happens.

As of today the problem is still in v5.17-rcX.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/1] i2c: smbus: Check for parent device before dereference
  2022-02-04 15:59 [PATCH v1 1/1] i2c: smbus: Check for parent device before dereference Andy Shevchenko
  2022-02-14 15:09 ` Andy Shevchenko
@ 2022-02-19 11:46 ` Wolfram Sang
  1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2022-02-19 11:46 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-i2c, linux-kernel, syzbot+0591ccf54ee05344e4eb

[-- Attachment #1: Type: text/plain, Size: 483 bytes --]

On Fri, Feb 04, 2022 at 05:59:20PM +0200, Andy Shevchenko wrote:
> An I²C adapter might be instantiated without parent. In such case
> there is no property can be retrieved. Skip SMBus alert setup when
> this happens.
> 
> Fixes: a263a84088f6 ("i2c: smbus: Use device_*() functions instead of of_*()")
> Reported-by: syzbot+0591ccf54ee05344e4eb@syzkaller.appspotmail.com
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Applied to for-next, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-02-19 11:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-04 15:59 [PATCH v1 1/1] i2c: smbus: Check for parent device before dereference Andy Shevchenko
2022-02-14 15:09 ` Andy Shevchenko
2022-02-19 11:46 ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).