Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1774493pxb; Wed, 9 Feb 2022 04:19:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJy8WUjrPL1yobe/fXtWTzhoxOaRzvYuu8AZJz4JfP3k0U/H9dP1wrs5NxIFQR79/tpyCHW/ X-Received: by 2002:a17:906:38c1:: with SMTP id r1mr1717165ejd.417.1644409178338; Wed, 09 Feb 2022 04:19:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644409178; cv=none; d=google.com; s=arc-20160816; b=RX3idhNSznBa019ranycGcgB+IP0wrPW320juxaxHQF5CIZpCwQtazk9LJBX8jniCW c7FXMvi15Rx11HFhUZHqj+uEn2q1DeBi0s+FzXWTby3o77rTNC7McJ33/hz8VGuN0YNl 1anuxCa6K3VSrFMsiSg0ICQxjE6oDYlKVlXgfuZQliApZolLag5rK3aiQkvNIL+SX0Z+ wNAuxRFvKXTNeNxgmp6IaBtrMsOXt+qyNFMiI8eYYkHdhsl0Qt8TPUYEXwtjRuGrRrhI i1vMv+Q73KYabGewC/srVg3yG3UotugCu9G6+T2rQ4bN8cbVLbdGyEX+HIsoEyP2OBjj ccYQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5iqfaPIDwp64eZmXN5Wz4kCRlQzQItlyRHY/jR7DkM0=; b=rdukX9gtki+YuS4YdlBq7b4OVQBZUUCsvkiVMmXKrXIIh+hasyoeATPUJDJt+dk2qP 6txtgwPH5/hFGhymykZ5lVA2mndD/BAuRLNQotOM0d2AUdM6ylHseEXaozULQiBLC2Me 05U4VbyPP65gBPCp3HJKUyDeAA7LKZqykc+0brOcNnsf/XJlwKhwJ43nvRhkb/lFCYWF o0OFscG267/3n6nvrlWBaS+LYUq02WPNpCNKtaShXHNpNQv65cgDyfXR3uG2pg5G+h/9 F5nxNEHwAdvgcj2llD3tAZGRGl/2BKIybMl0x9/vvXAFy+V1UxerkckDyNEX9WfB7vwH NvdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="1UKjbuA/"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sg8si10648557ejc.447.2022.02.09.04.19.11; Wed, 09 Feb 2022 04:19:38 -0800 (PST) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="1UKjbuA/"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389638AbiBGLu0 (ORCPT + 99 others); Mon, 7 Feb 2022 06:50:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380273AbiBGLaJ (ORCPT ); Mon, 7 Feb 2022 06:30:09 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 027B4C03E957; Mon, 7 Feb 2022 03:28:32 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8A8026077B; Mon, 7 Feb 2022 11:28:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 733BFC004E1; Mon, 7 Feb 2022 11:28:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233312; bh=gL+AJW7aUmc5Iap6xJjIKV40t3Yz1xThdKwzbu6TnWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1UKjbuA/p1pvwGSX/KqxDV5muIvTmKvkobZST/EIcHRsbNC429gBU0DyzChmZ+ta7 vdHKivlhguH48t5cL7/ln7TASFa+qpGbV7zfEXe1v95fZ/cRaqusQz3Aq+5LUW7WWu wbxJXeSnkz0d+BIfFDqLd2zJbAaJYOzG1woLVltc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Fainelli , Linus Walleij Subject: [PATCH 5.15 082/110] pinctrl: bcm2835: Fix a few error paths Date: Mon, 7 Feb 2022 12:06:55 +0100 Message-Id: <20220207103805.173542541@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Florian Fainelli commit 5297c693d8c8e08fa742e3112cf70723f7a04da2 upstream. After commit 266423e60ea1 ("pinctrl: bcm2835: Change init order for gpio hogs") a few error paths would not unwind properly the registration of gpio ranges. Correct that by assigning a single error label and goto it whenever we encounter a fatal error. Fixes: 266423e60ea1 ("pinctrl: bcm2835: Change init order for gpio hogs") Signed-off-by: Florian Fainelli Link: https://lore.kernel.org/r/20220127215033.267227-1-f.fainelli@gmail.com Signed-off-by: Linus Walleij Signed-off-by: Greg Kroah-Hartman --- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c @@ -1263,16 +1263,18 @@ static int bcm2835_pinctrl_probe(struct sizeof(*girq->parents), GFP_KERNEL); if (!girq->parents) { - pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range); - return -ENOMEM; + err = -ENOMEM; + goto out_remove; } if (is_7211) { pc->wake_irq = devm_kcalloc(dev, BCM2835_NUM_IRQS, sizeof(*pc->wake_irq), GFP_KERNEL); - if (!pc->wake_irq) - return -ENOMEM; + if (!pc->wake_irq) { + err = -ENOMEM; + goto out_remove; + } } /* @@ -1300,8 +1302,10 @@ static int bcm2835_pinctrl_probe(struct len = strlen(dev_name(pc->dev)) + 16; name = devm_kzalloc(pc->dev, len, GFP_KERNEL); - if (!name) - return -ENOMEM; + if (!name) { + err = -ENOMEM; + goto out_remove; + } snprintf(name, len, "%s:bank%d", dev_name(pc->dev), i); @@ -1320,11 +1324,14 @@ static int bcm2835_pinctrl_probe(struct err = gpiochip_add_data(&pc->gpio_chip, pc); if (err) { dev_err(dev, "could not add GPIO chip\n"); - pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range); - return err; + goto out_remove; } return 0; + +out_remove: + pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range); + return err; } static struct platform_driver bcm2835_pinctrl_driver = {