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

pinctrl: sirf: add missing put_device() call in sirfsoc_gpio_probe()

A coccicheck run provided information like the following:

drivers/pinctrl/sirf/pinctrl-sirf.c:798:2-8: ERROR: missing put_device;
call of_find_device_by_node on line 792, but without a corresponding
object release within this function.

Generated by: scripts/coccinelle/free/put_device.cocci

Thus add a jump target to fix the exception handling for this
function implementation.

Fixes: 5130216265f6 ("PINCTRL: SiRF: add GPIO and GPIO irq support in CSR SiRFprimaII")
Signed-off-by: yu kuai <yukuai3@huawei.com>
Link: https://lore.kernel.org/r/20200603013532.755220-1-yukuai3@huawei.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

yu kuai and committed by
Linus Walleij
66339f2f 9eb72832

+14 -6
+14 -6
drivers/pinctrl/sirf/pinctrl-sirf.c
··· 794 794 return -ENODEV; 795 795 796 796 sgpio = devm_kzalloc(&pdev->dev, sizeof(*sgpio), GFP_KERNEL); 797 - if (!sgpio) 798 - return -ENOMEM; 797 + if (!sgpio) { 798 + err = -ENOMEM; 799 + goto out_put_device; 800 + } 799 801 spin_lock_init(&sgpio->lock); 800 802 801 803 regs = of_iomap(np, 0); 802 - if (!regs) 803 - return -ENOMEM; 804 + if (!regs) { 805 + err = -ENOMEM; 806 + goto out_put_device; 807 + } 804 808 805 809 sgpio->chip.gc.request = sirfsoc_gpio_request; 806 810 sgpio->chip.gc.free = sirfsoc_gpio_free; ··· 828 824 girq->parents = devm_kcalloc(&pdev->dev, SIRFSOC_GPIO_NO_OF_BANKS, 829 825 sizeof(*girq->parents), 830 826 GFP_KERNEL); 831 - if (!girq->parents) 832 - return -ENOMEM; 827 + if (!girq->parents) { 828 + err = -ENOMEM; 829 + goto out_put_device; 830 + } 833 831 for (i = 0; i < SIRFSOC_GPIO_NO_OF_BANKS; i++) { 834 832 bank = &sgpio->sgpio_bank[i]; 835 833 spin_lock_init(&bank->lock); ··· 874 868 gpiochip_remove(&sgpio->chip.gc); 875 869 out: 876 870 iounmap(regs); 871 + out_put_device: 872 + put_device(&pdev->dev); 877 873 return err; 878 874 } 879 875