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

pinctrl: falcon: add missing put_device() call in pinctrl_falcon_probe()

if of_find_device_by_node() succeed, pinctrl_falcon_probe() doesn't have
a corresponding put_device(). Thus add put_device() to fix the exception
handling for this function implementation.

Fixes: e316cb2b16bb ("OF: pinctrl: MIPS: lantiq: adds support for FALCON SoC")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Link: https://lore.kernel.org/r/20201119011219.2248232-1-yukuai3@huawei.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Yu Kuai and committed by
Linus Walleij
89cce2b3 43bb48c3

+9 -5
+9 -5
drivers/pinctrl/pinctrl-falcon.c
··· 431 431 432 432 /* load and remap the pad resources of the different banks */ 433 433 for_each_compatible_node(np, NULL, "lantiq,pad-falcon") { 434 - struct platform_device *ppdev = of_find_device_by_node(np); 435 434 const __be32 *bank = of_get_property(np, "lantiq,bank", NULL); 436 435 struct resource res; 436 + struct platform_device *ppdev; 437 437 u32 avail; 438 438 int pins; 439 439 440 440 if (!of_device_is_available(np)) 441 441 continue; 442 442 443 - if (!ppdev) { 444 - dev_err(&pdev->dev, "failed to find pad pdev\n"); 445 - continue; 446 - } 447 443 if (!bank || *bank >= PORTS) 448 444 continue; 449 445 if (of_address_to_resource(np, 0, &res)) 450 446 continue; 447 + 448 + ppdev = of_find_device_by_node(np); 449 + if (!ppdev) { 450 + dev_err(&pdev->dev, "failed to find pad pdev\n"); 451 + continue; 452 + } 453 + 451 454 falcon_info.clk[*bank] = clk_get(&ppdev->dev, NULL); 455 + put_device(&ppdev->dev); 452 456 if (IS_ERR(falcon_info.clk[*bank])) { 453 457 dev_err(&ppdev->dev, "failed to get clock\n"); 454 458 of_node_put(np);