mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 22:21:40 +00:00
gpio: merrifield: check the return value of devm_kstrdup()
devm_kstrdup() returns pointer to allocated string on success, NULL on failure. So it is better to check the return value of it. Before, if devm_kstrdup() fails, pinctrl_dev_name will be NULL, then the retval below will be a negative error-code (inside gpiochip_add_pin_range(), pinctrl_find_and_add_gpio_range()->get_pinctrl_dev_from_devname() will finally check pinctrl_dev_name and return an error), so the failure of devm_kstrdup() can be only implicitly caught after a long call chain. While this patch is to explicitly catch the failure in time. Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
This commit is contained in:
parent
06608bc2d9
commit
c84eab5850
@ -409,6 +409,9 @@ static int mrfld_gpio_add_pin_ranges(struct gpio_chip *chip)
|
||||
int retval;
|
||||
|
||||
pinctrl_dev_name = mrfld_gpio_get_pinctrl_dev_name(priv);
|
||||
if (!pinctrl_dev_name)
|
||||
return -ENOMEM;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(mrfld_gpio_ranges); i++) {
|
||||
range = &mrfld_gpio_ranges[i];
|
||||
retval = gpiochip_add_pin_range(&priv->chip, pinctrl_dev_name,
|
||||
|
Loading…
Reference in New Issue
Block a user