diff options
author | Axel Lin <axel.lin@ingics.com> | 2012-11-21 01:33:56 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2012-11-21 04:08:05 -0500 |
commit | b4d4b1f087b9d4d730eb70f24032395d7cd7e591 (patch) | |
tree | baca0b7810c3b0966e4f7ba65088a01d77df7b98 /drivers/gpio/gpiolib.c | |
parent | 316511c0134acec8f4ea730bd1897c7a1124a7c1 (diff) |
gpiolib: Fix use after free in gpiochip_add_pin_range
This is introduced by commit 9ab6e988
"gpiolib: return any error code from range creation".
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r-- | drivers/gpio/gpiolib.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 26e27c1fecb1..58b9838801c0 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -1201,6 +1201,7 @@ int gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name, | |||
1201 | unsigned int npins) | 1201 | unsigned int npins) |
1202 | { | 1202 | { |
1203 | struct gpio_pin_range *pin_range; | 1203 | struct gpio_pin_range *pin_range; |
1204 | int ret; | ||
1204 | 1205 | ||
1205 | pin_range = kzalloc(sizeof(*pin_range), GFP_KERNEL); | 1206 | pin_range = kzalloc(sizeof(*pin_range), GFP_KERNEL); |
1206 | if (!pin_range) { | 1207 | if (!pin_range) { |
@@ -1219,10 +1220,11 @@ int gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name, | |||
1219 | pin_range->pctldev = pinctrl_find_and_add_gpio_range(pinctl_name, | 1220 | pin_range->pctldev = pinctrl_find_and_add_gpio_range(pinctl_name, |
1220 | &pin_range->range); | 1221 | &pin_range->range); |
1221 | if (IS_ERR(pin_range->pctldev)) { | 1222 | if (IS_ERR(pin_range->pctldev)) { |
1223 | ret = PTR_ERR(pin_range->pctldev); | ||
1222 | pr_err("%s: GPIO chip: could not create pin range\n", | 1224 | pr_err("%s: GPIO chip: could not create pin range\n", |
1223 | chip->label); | 1225 | chip->label); |
1224 | kfree(pin_range); | 1226 | kfree(pin_range); |
1225 | return PTR_ERR(pin_range->pctldev); | 1227 | return ret; |
1226 | } | 1228 | } |
1227 | pr_debug("GPIO chip %s: created GPIO range %d->%d ==> %s PIN %d->%d\n", | 1229 | pr_debug("GPIO chip %s: created GPIO range %d->%d ==> %s PIN %d->%d\n", |
1228 | chip->label, gpio_offset, gpio_offset + npins - 1, | 1230 | chip->label, gpio_offset, gpio_offset + npins - 1, |