aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorKrzysztof Kozlowski <k.kozlowski@samsung.com>2014-03-06 04:31:16 -0500
committerLinus Walleij <linus.walleij@linaro.org>2014-03-12 09:50:51 -0400
commitf561b4230cec90137baeba1b1c9302461939b870 (patch)
treede04fd6a5d6f86c76a3663e46a04c05c1f661177 /drivers/gpio
parentc75793d8ab743acdd07120cf11c0242daea8f780 (diff)
gpio: max732x: Fix possible NULL pointer dereference on i2c_new_dummy error
In max732x_probe() driver allocates dummy I2C device (if number of ports is greater than 8) with i2c_new_dummy() but it does not check the return value of this call. In case of error (i2c_new_device(): memory allocation failure or I2C address cannot be used) this function returns NULL which is later dereferenced by i2c_smbus_read_byte() (called from max732x_readb()). Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpio-max732x.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-max732x.c b/drivers/gpio/gpio-max732x.c
index 74432daaf656..7c36f2b0983d 100644
--- a/drivers/gpio/gpio-max732x.c
+++ b/drivers/gpio/gpio-max732x.c
@@ -622,6 +622,13 @@ static int max732x_probe(struct i2c_client *client,
622 goto out_failed; 622 goto out_failed;
623 } 623 }
624 624
625 if (nr_port > 8 && !chip->client_dummy) {
626 dev_err(&client->dev,
627 "Failed to allocate second group I2C device\n");
628 ret = -ENODEV;
629 goto out_failed;
630 }
631
625 mutex_init(&chip->lock); 632 mutex_init(&chip->lock);
626 633
627 max732x_readb(chip, is_group_a(chip, 0), &chip->reg_out[0]); 634 max732x_readb(chip, is_group_a(chip, 0), &chip->reg_out[0]);