Skip to contentSkip to conversation

serial: max310x: Add error checking in probe()

PATCH In review Dan Carpenter 2 participants 2 messages Aug 7, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial: max310x: Add error checking in probe()

Check if devm_i2c_new_dummy_device() fails.

Fixes 2e1f2d9a9bdb ("serial: max310x: implement I2C support")
---
 drivers/tty/serial/max310x.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/tty/serial/max310x.c +2 -0
index 541c790c0109..2b42a4c21a9b 100644
@@ -1644,6 +1644,8 @@ static int max310x_i2c_probe(struct i2c_client *client)
 		port_client = devm_i2c_new_dummy_device(&client->dev,
 							client->adapter,
 							port_addr);
+		if (IS_ERR(port_client))
+			return PTR_ERR(port_client);
 
 		regcfg_i2c.name = max310x_regmap_name(i);
 		regmaps[i] = devm_regmap_init_i2c(port_client, &regcfg_i2c);
Signature · 1 line
2.47.2
#1 lore raw
Quoted 2 lines · Dan Carpenter

Check if devm_i2c_new_dummy_device() fails.

...

drivers/tty/serial/max310x.c static int max310x_i2c_probe(struct i2c_client *client) · line 1648

Quoted 5 lines
                port_client = devm_i2c_new_dummy_device(&client->dev,
                                                        client->adapter,
                                                        port_addr);
drivers/tty/serial/max310x.c +2 -0
+               if (IS_ERR(port_client))
+                       return PTR_ERR(port_client);

I'm wondering if this is indeed a critical error in this case, but okay.

Signature · 2 lines
With Best Regards,
Andy Shevchenko