All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpio: max732x: add error handling for i2c_new_dummy
@ 2018-06-12  3:28 ` Zhouyang Jia
  0 siblings, 0 replies; 5+ messages in thread
From: Zhouyang Jia @ 2018-06-12  3:28 UTC (permalink / raw)
  Cc: Zhouyang Jia, Linus Walleij, linux-gpio, linux-kernel

When i2c_new_dummy fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling i2c_new_dummy.

Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
 drivers/gpio/gpio-max732x.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpio/gpio-max732x.c b/drivers/gpio/gpio-max732x.c
index 9d8bcc6..f03cb0b 100644
--- a/drivers/gpio/gpio-max732x.c
+++ b/drivers/gpio/gpio-max732x.c
@@ -653,6 +653,12 @@ static int max732x_probe(struct i2c_client *client,
 		chip->client_group_a = client;
 		if (nr_port > 8) {
 			c = i2c_new_dummy(client->adapter, addr_b);
+			if (!c) {
+				dev_err(&client->dev,
+					"Failed to allocate I2C device\n");
+				ret = -ENODEV;
+				goto out_failed;
+			}
 			chip->client_group_b = chip->client_dummy = c;
 		}
 		break;
@@ -660,6 +666,12 @@ static int max732x_probe(struct i2c_client *client,
 		chip->client_group_b = client;
 		if (nr_port > 8) {
 			c = i2c_new_dummy(client->adapter, addr_a);
+			if (!c) {
+				dev_err(&client->dev,
+					"Failed to allocate I2C device\n");
+				ret = -ENODEV;
+				goto out_failed;
+			}
 			chip->client_group_a = chip->client_dummy = c;
 		}
 		break;
-- 
2.7.4

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

* [PATCH] gpio: max732x: add error handling for i2c_new_dummy
@ 2018-06-12  3:28 ` Zhouyang Jia
  0 siblings, 0 replies; 5+ messages in thread
From: Zhouyang Jia @ 2018-06-12  3:28 UTC (permalink / raw)
  Cc: Zhouyang Jia, Linus Walleij, linux-gpio, linux-kernel

When i2c_new_dummy fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling i2c_new_dummy.

Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
 drivers/gpio/gpio-max732x.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpio/gpio-max732x.c b/drivers/gpio/gpio-max732x.c
index 9d8bcc6..f03cb0b 100644
--- a/drivers/gpio/gpio-max732x.c
+++ b/drivers/gpio/gpio-max732x.c
@@ -653,6 +653,12 @@ static int max732x_probe(struct i2c_client *client,
 		chip->client_group_a = client;
 		if (nr_port > 8) {
 			c = i2c_new_dummy(client->adapter, addr_b);
+			if (!c) {
+				dev_err(&client->dev,
+					"Failed to allocate I2C device\n");
+				ret = -ENODEV;
+				goto out_failed;
+			}
 			chip->client_group_b = chip->client_dummy = c;
 		}
 		break;
@@ -660,6 +666,12 @@ static int max732x_probe(struct i2c_client *client,
 		chip->client_group_b = client;
 		if (nr_port > 8) {
 			c = i2c_new_dummy(client->adapter, addr_a);
+			if (!c) {
+				dev_err(&client->dev,
+					"Failed to allocate I2C device\n");
+				ret = -ENODEV;
+				goto out_failed;
+			}
 			chip->client_group_a = chip->client_dummy = c;
 		}
 		break;
-- 
2.7.4


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

* Re: [PATCH] gpio: max732x: add error handling for i2c_new_dummy
  2018-06-12  3:28 ` Zhouyang Jia
  (?)
@ 2018-06-12  8:32 ` Andy Shevchenko
  -1 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2018-06-12  8:32 UTC (permalink / raw)
  To: Zhouyang Jia
  Cc: Linus Walleij, open list:GPIO SUBSYSTEM, Linux Kernel Mailing List

On Tue, Jun 12, 2018 at 6:28 AM, Zhouyang Jia <jiazhouyang09@gmail.com> wrote:
> When i2c_new_dummy fails, the lack of error-handling code may
> cause unexpected results.

What results?
Where is the analisys?

Would driver work w/o these dummy devices?

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH] gpio: max732x: add error handling for i2c_new_dummy
  2018-06-12  3:28 ` Zhouyang Jia
  (?)
  (?)
@ 2018-06-14 14:27 ` Linus Walleij
  2018-06-15  9:01   ` Andy Shevchenko
  -1 siblings, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2018-06-14 14:27 UTC (permalink / raw)
  To: Zhouyang Jia; +Cc: open list:GPIO SUBSYSTEM, linux-kernel

On Tue, Jun 12, 2018 at 5:28 AM, Zhouyang Jia <jiazhouyang09@gmail.com> wrote:

> When i2c_new_dummy fails, the lack of error-handling code may
> cause unexpected results.
>
> This patch adds error-handling code after calling i2c_new_dummy.
>
> Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>

Patch applied for non-critical fixes.

Yours,
Linus Walleij

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

* Re: [PATCH] gpio: max732x: add error handling for i2c_new_dummy
  2018-06-14 14:27 ` Linus Walleij
@ 2018-06-15  9:01   ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2018-06-15  9:01 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Zhouyang Jia, open list:GPIO SUBSYSTEM, linux-kernel

On Thu, Jun 14, 2018 at 5:27 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Tue, Jun 12, 2018 at 5:28 AM, Zhouyang Jia <jiazhouyang09@gmail.com> wrote:
>
>> When i2c_new_dummy fails, the lack of error-handling code may
>> cause unexpected results.
>>
>> This patch adds error-handling code after calling i2c_new_dummy.
>>
>> Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
>
> Patch applied for non-critical fixes.

It might potentially be a regression if the driver used to work when
dummy device creation failed.

>
> Yours,
> Linus Walleij



-- 
With Best Regards,
Andy Shevchenko

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

end of thread, other threads:[~2018-06-15  9:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-12  3:28 [PATCH] gpio: max732x: add error handling for i2c_new_dummy Zhouyang Jia
2018-06-12  3:28 ` Zhouyang Jia
2018-06-12  8:32 ` Andy Shevchenko
2018-06-14 14:27 ` Linus Walleij
2018-06-15  9:01   ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.