Thread (12 messages) 12 messages, 3 authors, 2017-05-02
STALE3341d
Revisions (3)
  1. v5 current
  2. v7 [diff vs current]
  3. v10 [diff vs current]

[PATCH v5 2/9] i2c: i2c-smbus: Add null ptr guard in smb_alert_probe

From: Phil Reid <hidden>
Date: 2017-05-01 08:49:52
Also in: linux-i2c, linux-pm
Subsystem: i2c subsystem, the rest · Maintainers: Andi Shyti, Linus Torvalds

If platdata is not correct setup before registering the device
a null ptr derefence can occur.

Signed-off-by: Phil Reid <redacted>
---
 drivers/i2c/i2c-smbus.c | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/drivers/i2c/i2c-smbus.c b/drivers/i2c/i2c-smbus.c
index b272493..df0e2fa 100644
--- a/drivers/i2c/i2c-smbus.c
+++ b/drivers/i2c/i2c-smbus.c
@@ -151,6 +151,11 @@ static int smbalert_probe(struct i2c_client *ara,
 	struct i2c_adapter *adapter = ara->adapter;
 	int res;
 
+	if (!setup) {
+		dev_err(&adapter->dev, "setup not defined\n");
+		return -ENODATA;
+	}
+
 	alert = devm_kzalloc(&ara->dev, sizeof(struct i2c_smbus_alert),
 			     GFP_KERNEL);
 	if (!alert)
-- 
1.8.3.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help