From patchwork Wed Jun 3 01:35:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 206856 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BCDFC433DF for ; Wed, 3 Jun 2020 01:36:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 594D4206E9 for ; Wed, 3 Jun 2020 01:36:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728321AbgFCBgI (ORCPT ); Tue, 2 Jun 2020 21:36:08 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:5774 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726894AbgFCBgH (ORCPT ); Tue, 2 Jun 2020 21:36:07 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 5C91D8505ADF3CA3FC15; Wed, 3 Jun 2020 09:36:02 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.487.0; Wed, 3 Jun 2020 09:35:51 +0800 From: yu kuai To: , , , CC: , , , , Subject: [PATCH V2] pinctrl: sirf: add missing put_device() call in sirfsoc_gpio_probe() Date: Wed, 3 Jun 2020 09:35:32 +0800 Message-ID: <20200603013532.755220-1-yukuai3@huawei.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 X-Originating-IP: [10.175.104.175] X-CFilter-Loop: Reflected Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org 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 --- drivers/pinctrl/sirf/pinctrl-sirf.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/sirf/pinctrl-sirf.c b/drivers/pinctrl/sirf/pinctrl-sirf.c index 1ebcb957c654..63a287d5795f 100644 --- a/drivers/pinctrl/sirf/pinctrl-sirf.c +++ b/drivers/pinctrl/sirf/pinctrl-sirf.c @@ -794,13 +794,17 @@ static int sirfsoc_gpio_probe(struct device_node *np) return -ENODEV; sgpio = devm_kzalloc(&pdev->dev, sizeof(*sgpio), GFP_KERNEL); - if (!sgpio) - return -ENOMEM; + if (!sgpio) { + err = -ENOMEM; + goto out_put_device; + } spin_lock_init(&sgpio->lock); regs = of_iomap(np, 0); - if (!regs) - return -ENOMEM; + if (!regs) { + err = -ENOMEM; + goto out_put_device; + } sgpio->chip.gc.request = sirfsoc_gpio_request; sgpio->chip.gc.free = sirfsoc_gpio_free; @@ -824,8 +828,10 @@ static int sirfsoc_gpio_probe(struct device_node *np) girq->parents = devm_kcalloc(&pdev->dev, SIRFSOC_GPIO_NO_OF_BANKS, sizeof(*girq->parents), GFP_KERNEL); - if (!girq->parents) - return -ENOMEM; + if (!girq->parents) { + err = -ENOMEM; + goto out_put_device; + } for (i = 0; i < SIRFSOC_GPIO_NO_OF_BANKS; i++) { bank = &sgpio->sgpio_bank[i]; spin_lock_init(&bank->lock); @@ -868,6 +874,8 @@ static int sirfsoc_gpio_probe(struct device_node *np) gpiochip_remove(&sgpio->chip.gc); out: iounmap(regs); +out_put_device: + put_device(&pdev->dev); return err; }