Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1575163pxb; Fri, 20 Aug 2021 08:41:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIEvATkKaJpWosQUoKaAvmUJXHbimXWvi+3Ev210anUH1s2ST6f6CJ3AuCpGt/UzCTvQf9 X-Received: by 2002:a17:906:b74f:: with SMTP id fx15mr19177575ejb.95.1629474101742; Fri, 20 Aug 2021 08:41:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629474101; cv=none; d=google.com; s=arc-20160816; b=MCSOO5FQ9lbG+OuNRpeKVYOymIYlbz/Y7E1JkJcPStIwSKOatdiufQrjhiyZbPyR+e Dro/VjD/cL7Nzu3jccg0AkZrRBsOYuS3zbxfWvla6OfsPq9ULgrfZO1JnRPe2Ai3KeJU JUtNfbJKDQaoEC3z9bKCFOD4R8wK4s5fHfe3wxX5l8Wu2szT9RNWSX6IqMjhEZPr69G5 JK3eALPbCnVtus3IDF03dItCO5NYuMQfx9/qVNFrHPivqBcaTI4hyv765b5CNsmIkCuv 24yhjxnPXNj3pROci3IytmGsYM2ZWz8ETWEFL302fF4Q0mNsLjSHg6pCRRfIBwK5tHi2 ATew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=xxZzct/1hawyShZiPiGHcaC7INhrTH7tC1Q72p7n0g8=; b=ntTRLNQVszIpm69X9Qa3cg3NBY7LyYjU3zdbAO/+MN2gYZUxAxffyFwuok+bODhB9v /JQiG28cgP6WyTbky0h85bASrNFSZehtB8MA/UuT+eXFBSfK4oRPmOlhBEhrM1fjWH9g fuDJ4Pa5Mx2ncDc8rKTUfz8wdIZRlrmfVbNPpyz3S+8unvUylTJ6z/oZZKVnIaqe7teB DcH2HCKcVjWhbm1iXRWb6z/CSZi3Yd2YXPVs7SltIS3XhWhc532/bX0zGxsdsv6QF2Zd t/tIo4Amm1HuzYzC3CoVdnUcarTcob/AjDIt1Y2GKWyBLYRxTFU9gNDlXymLAhOEhQVc Jh2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ji10si3734751ejc.496.2021.08.20.08.41.14; Fri, 20 Aug 2021 08:41:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241100AbhHTPip (ORCPT + 99 others); Fri, 20 Aug 2021 11:38:45 -0400 Received: from smtp09.smtpout.orange.fr ([80.12.242.131]:56792 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241120AbhHTPin (ORCPT ); Fri, 20 Aug 2021 11:38:43 -0400 Received: from pop-os.home ([90.126.253.178]) by mwinf5d04 with ME id jre42500U3riaq203re415; Fri, 20 Aug 2021 17:38:05 +0200 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 20 Aug 2021 17:38:05 +0200 X-ME-IP: 90.126.253.178 From: Christophe JAILLET To: linus.walleij@linaro.org, bgolaszewski@baylibre.com, alexandru.marginean@nxp.com, Laurentiu.Tudor@nxp.com, hui.song_1@nxp.com, andy.shevchenko@gmail.com, ran.wang_1@nxp.com Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH 2/3] gpio: mpc8xxx: Fix a potential double iounmap call in 'mpc8xxx_probe()' Date: Fri, 20 Aug 2021 17:38:03 +0200 Message-Id: <5341e631dc93902ef13840807163a2883764b8ed.1629472813.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 76c47d1449fc ("gpio: mpc8xxx: Add ACPI support") has switched to a managed version when dealing with 'mpc8xxx_gc->regs'. So the corresponding 'iounmap()' call in the error handling path and in the remove should be removed to avoid a double unmap. This also allows some simplification in the probe. All the error handling paths related to managed resources can be direct returns and a NULL check in what remains in the error handling path can be removed. Fixes: 76c47d1449fc ("gpio: mpc8xxx: Add ACPI support") Signed-off-by: Christophe JAILLET --- drivers/gpio/gpio-mpc8xxx.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c index 241bcc80612e..fa4aaeced3f1 100644 --- a/drivers/gpio/gpio-mpc8xxx.c +++ b/drivers/gpio/gpio-mpc8xxx.c @@ -332,7 +332,7 @@ static int mpc8xxx_probe(struct platform_device *pdev) mpc8xxx_gc->regs + GPIO_DIR, NULL, BGPIOF_BIG_ENDIAN); if (ret) - goto err; + return ret; dev_dbg(&pdev->dev, "GPIO registers are LITTLE endian\n"); } else { ret = bgpio_init(gc, &pdev->dev, 4, @@ -342,7 +342,7 @@ static int mpc8xxx_probe(struct platform_device *pdev) BGPIOF_BIG_ENDIAN | BGPIOF_BIG_ENDIAN_BYTE_ORDER); if (ret) - goto err; + return ret; dev_dbg(&pdev->dev, "GPIO registers are BIG endian\n"); } @@ -384,7 +384,7 @@ static int mpc8xxx_probe(struct platform_device *pdev) if (ret) { dev_err(&pdev->dev, "GPIO chip registration failed with status %d\n", ret); - goto err; + return ret; } mpc8xxx_gc->irqn = platform_get_irq(pdev, 0); @@ -416,9 +416,7 @@ static int mpc8xxx_probe(struct platform_device *pdev) return 0; err: - if (mpc8xxx_gc->irq) - irq_domain_remove(mpc8xxx_gc->irq); - iounmap(mpc8xxx_gc->regs); + irq_domain_remove(mpc8xxx_gc->irq); return ret; } @@ -432,7 +430,6 @@ static int mpc8xxx_remove(struct platform_device *pdev) } gpiochip_remove(&mpc8xxx_gc->gc); - iounmap(mpc8xxx_gc->regs); return 0; } -- 2.30.2