From patchwork Tue Feb 5 19:48:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 2098901 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id A26C53FDF1 for ; Tue, 5 Feb 2013 19:51:47 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1U2oW6-0001As-IO; Tue, 05 Feb 2013 19:49:18 +0000 Received: from eu1sys200aog107.obsmtp.com ([207.126.144.123]) by merlin.infradead.org with smtps (Exim 4.76 #1 (Red Hat Linux)) id 1U2oW0-000170-23 for linux-arm-kernel@lists.infradead.org; Tue, 05 Feb 2013 19:49:14 +0000 Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob107.postini.com ([207.126.147.11]) with SMTP ID DSNKURFiMAncEYOLSoX7sJ5cXBaZ3GjbC8WH@postini.com; Tue, 05 Feb 2013 19:49:11 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 78BAD101; Tue, 5 Feb 2013 19:49:03 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 33876522A; Tue, 5 Feb 2013 19:49:03 +0000 (GMT) Received: from exdcvycastm022.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm022", Issuer "exdcvycastm022" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id 59DAEA8072; Tue, 5 Feb 2013 20:48:55 +0100 (CET) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.30) with Microsoft SMTP Server (TLS) id 8.3.83.0; Tue, 5 Feb 2013 20:49:02 +0100 From: Linus Walleij To: , Subject: [PATCH 05/14] pinctrl/abx500: prevent error path from corrupting returning error Date: Tue, 5 Feb 2013 20:48:26 +0100 Message-ID: <1360093715-6348-6-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1360093715-6348-1-git-send-email-linus.walleij@stericsson.com> References: <1360093715-6348-1-git-send-email-linus.walleij@stericsson.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130205_144912_339773_F24820B6 X-CRM114-Status: GOOD ( 17.42 ) X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [207.126.144.123 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Anmar Oueja , Lee Jones , Linus Walleij , Stephen Warren X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Lee Jones Prior to this patch abx500_gpio_probe() would return the return-value of gpiochip_remove() during its error patch regardless of what the actual failure was. So as long as gpiochip_remove() succeeded, probe() would look like it succeeded too. This patch ensures the correct error value is returned and that mutex_destroy() is invoked if gpiochip_add_pin_range() were to fail. Signed-off-by: Lee Jones Signed-off-by: Linus Walleij --- drivers/pinctrl/pinctrl-abx500.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/pinctrl/pinctrl-abx500.c b/drivers/pinctrl/pinctrl-abx500.c index 81ef515..9bdfcb9 100644 --- a/drivers/pinctrl/pinctrl-abx500.c +++ b/drivers/pinctrl/pinctrl-abx500.c @@ -1111,7 +1111,7 @@ static int abx500_gpio_probe(struct platform_device *pdev) struct abx500_gpio_platform_data *pdata; struct abx500_pinctrl *pct; const struct platform_device_id *platid = platform_get_device_id(pdev); - int ret; + int ret, err; int i; pdata = abx500_pdata->gpio; @@ -1189,6 +1189,7 @@ static int abx500_gpio_probe(struct platform_device *pdev) if (!pct->pctldev) { dev_err(&pdev->dev, "could not register abx500 pinctrl driver\n"); + ret = -EINVAL; goto out_rem_chip; } dev_info(&pdev->dev, "registered pin controller\n"); @@ -1201,7 +1202,7 @@ static int abx500_gpio_probe(struct platform_device *pdev) dev_name(&pdev->dev), p->offset - 1, p->offset, p->npins); if (ret < 0) - return ret; + goto out_rem_chip; } platform_set_drvdata(pdev, pct); @@ -1210,8 +1211,8 @@ static int abx500_gpio_probe(struct platform_device *pdev) return 0; out_rem_chip: - ret = gpiochip_remove(&pct->chip); - if (ret) + err = gpiochip_remove(&pct->chip); + if (err) dev_info(&pdev->dev, "failed to remove gpiochip\n"); out_rem_irq: abx500_gpio_irq_remove(pct);