[PATCH] serial: max310x: Add error checking in probe()

Dan Carpenter posted 1 patch 1 month, 4 weeks ago
drivers/tty/serial/max310x.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] serial: max310x: Add error checking in probe()
Posted by Dan Carpenter 1 month, 4 weeks ago
Check if devm_i2c_new_dummy_device() fails.

Fixes: 2e1f2d9a9bdb ("serial: max310x: implement I2C support")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/tty/serial/max310x.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
index 541c790c0109..2b42a4c21a9b 100644
--- a/drivers/tty/serial/max310x.c
+++ b/drivers/tty/serial/max310x.c
@@ -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);
-- 
2.47.2
Re: [PATCH] serial: max310x: Add error checking in probe()
Posted by Andy Shevchenko 1 month, 4 weeks ago
On Thu, Aug 7, 2025 at 5:54 PM Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> Check if devm_i2c_new_dummy_device() fails.

...

>                 port_client = devm_i2c_new_dummy_device(&client->dev,
>                                                         client->adapter,
>                                                         port_addr);
> +               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.

-- 
With Best Regards,
Andy Shevchenko