mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-13 09:20:17 +00:00
pinctrl: nomadik: fix possible object reference leak
The of_find_device_by_node takes a reference to the struct device when find the match device ,we should release it when fail. Signed-off-by: WangBo <wang.bo116@zte.com.cn> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
e003ec6aa9
commit
7c6daeaf0a
@ -1056,17 +1056,22 @@ static struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np,
|
|||||||
}
|
}
|
||||||
if (of_property_read_u32(np, "gpio-bank", &id)) {
|
if (of_property_read_u32(np, "gpio-bank", &id)) {
|
||||||
dev_err(&pdev->dev, "populate: gpio-bank property not found\n");
|
dev_err(&pdev->dev, "populate: gpio-bank property not found\n");
|
||||||
|
platform_device_put(gpio_pdev);
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Already populated? */
|
/* Already populated? */
|
||||||
nmk_chip = nmk_gpio_chips[id];
|
nmk_chip = nmk_gpio_chips[id];
|
||||||
if (nmk_chip)
|
if (nmk_chip) {
|
||||||
|
platform_device_put(gpio_pdev);
|
||||||
return nmk_chip;
|
return nmk_chip;
|
||||||
|
}
|
||||||
|
|
||||||
nmk_chip = devm_kzalloc(&pdev->dev, sizeof(*nmk_chip), GFP_KERNEL);
|
nmk_chip = devm_kzalloc(&pdev->dev, sizeof(*nmk_chip), GFP_KERNEL);
|
||||||
if (!nmk_chip)
|
if (!nmk_chip) {
|
||||||
|
platform_device_put(gpio_pdev);
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
|
}
|
||||||
|
|
||||||
nmk_chip->bank = id;
|
nmk_chip->bank = id;
|
||||||
chip = &nmk_chip->chip;
|
chip = &nmk_chip->chip;
|
||||||
@ -1077,13 +1082,17 @@ static struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np,
|
|||||||
|
|
||||||
res = platform_get_resource(gpio_pdev, IORESOURCE_MEM, 0);
|
res = platform_get_resource(gpio_pdev, IORESOURCE_MEM, 0);
|
||||||
base = devm_ioremap_resource(&pdev->dev, res);
|
base = devm_ioremap_resource(&pdev->dev, res);
|
||||||
if (IS_ERR(base))
|
if (IS_ERR(base)) {
|
||||||
|
platform_device_put(gpio_pdev);
|
||||||
return ERR_CAST(base);
|
return ERR_CAST(base);
|
||||||
|
}
|
||||||
nmk_chip->addr = base;
|
nmk_chip->addr = base;
|
||||||
|
|
||||||
clk = clk_get(&gpio_pdev->dev, NULL);
|
clk = clk_get(&gpio_pdev->dev, NULL);
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(clk)) {
|
||||||
|
platform_device_put(gpio_pdev);
|
||||||
return (void *) clk;
|
return (void *) clk;
|
||||||
|
}
|
||||||
clk_prepare(clk);
|
clk_prepare(clk);
|
||||||
nmk_chip->clk = clk;
|
nmk_chip->clk = clk;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user