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: 14560 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 3A07123E92 for ; Tue, 5 Feb 2013 19:49:14 +0000 (UTC) Received: from mail-vb0-f54.google.com (mail-vb0-f54.google.com [209.85.212.54]) by fiordland.canonical.com (Postfix) with ESMTP id D3DC7A1883C for ; Tue, 5 Feb 2013 19:49:13 +0000 (UTC) Received: by mail-vb0-f54.google.com with SMTP id l1so316019vba.41 for ; Tue, 05 Feb 2013 11:49:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:mime-version:content-type:x-gm-message-state; bh=9RvI+C7q93RxBteMvRRV7C+KU/lA8jbXIhLJCoaRozs=; b=CHihfCL+DVw48uCPIFZhtV6z6FJ4WIjaXgaFN1HxCczGHyq0JX5JFq4KhO4HqPdToU 78hE66qSnBcYTNuSpYAlx8emy/yngZpHgC6wsJfRA6CA58B0ln2yNfOn5BaHNO/qVqPc Ae2il21RCn40gNzrup2cRxgHtFjGx/4KJlm+jb/r5h4phHNjWNg7CVZbn+zCEMhPXoAo mx95Q2RIFL7E5m8smfzAuVws61fEfKv9EFX9q07+zSb9SafClhP+ScDEDLY5++owQDpX WeQcCyuwfy8Ik3Xv/FMsdzDCEJ101UzQCoNdoumOGJrCkY0H88Ml/zThwFprm/j0cJm8 wkyA== X-Received: by 10.58.231.196 with SMTP id ti4mr25536385vec.25.1360093753374; Tue, 05 Feb 2013 11:49:13 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.252.8 with SMTP id zo8csp143953vec; Tue, 5 Feb 2013 11:49:12 -0800 (PST) X-Received: by 10.14.225.133 with SMTP id z5mr89114217eep.15.1360093752017; Tue, 05 Feb 2013 11:49:12 -0800 (PST) Received: from eu1sys200aog107.obsmtp.com (eu1sys200aog107.obsmtp.com [207.126.144.123]) by mx.google.com with SMTP id x41si36942326eeo.126.2013.02.05.11.49.04 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 05 Feb 2013 11:49:12 -0800 (PST) Received-SPF: neutral (google.com: 207.126.144.123 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.123; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.123 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com 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: , Cc: Stephen Warren , Anmar Oueja , Lee Jones , Linus Walleij 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-Gm-Message-State: ALoCoQkmAXkJccyOUzpE4pnBhX0e3jznZDab1eNFJ+ofbPlXQgHxVjrwjXKlAqRU09xuD3YqmXNY 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);