Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: max732x: add error handling for i2c_new_dummy

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>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Zhouyang Jia and committed by
Linus Walleij
f3a049e7 eb3744a2

+12
+12
drivers/gpio/gpio-max732x.c
··· 653 653 chip->client_group_a = client; 654 654 if (nr_port > 8) { 655 655 c = i2c_new_dummy(client->adapter, addr_b); 656 + if (!c) { 657 + dev_err(&client->dev, 658 + "Failed to allocate I2C device\n"); 659 + ret = -ENODEV; 660 + goto out_failed; 661 + } 656 662 chip->client_group_b = chip->client_dummy = c; 657 663 } 658 664 break; ··· 666 660 chip->client_group_b = client; 667 661 if (nr_port > 8) { 668 662 c = i2c_new_dummy(client->adapter, addr_a); 663 + if (!c) { 664 + dev_err(&client->dev, 665 + "Failed to allocate I2C device\n"); 666 + ret = -ENODEV; 667 + goto out_failed; 668 + } 669 669 chip->client_group_a = chip->client_dummy = c; 670 670 } 671 671 break;