Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1716346pxb; Wed, 9 Feb 2022 03:00:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJzPQT1JLZmfzcPCsfH/6Q1F/aqgrdc3Aj95FH8OkN2HYB1h37YupXLVi2suSXRy0qQzcu60 X-Received: by 2002:a17:90b:4f89:: with SMTP id qe9mr1897418pjb.59.1644404420984; Wed, 09 Feb 2022 03:00:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644404420; cv=none; d=google.com; s=arc-20160816; b=PuZIUwpJzj836KAJLeAW/0AHLhwzaYVQ36O8eYMJN5vLu//DDxQU6hzfJAgXxDgiFR wQEMPAB4Bw+el5o9U/HE8CR2/giflAGdjjejx+3lcZx/k0jibsokhqvMWUJVG5klQRF8 wdB6c/P/YhTsB9b4AvzNHx7Ug3TYA4fXPKkSFn2QoUKshYIDKQs4jjlCvHm2NScppG72 eO+0KmjJlXkeA3BQcaN/5LuGgxcilvTadHVwDbbg3EKfA6Xr+3REiGofK5FjRBKhk94p qzip7QAmDU3E117c5gSaFhetqCpCFxSSp+eH6PgJG/vMNCHfMcPAKb5nn6Yy68Z24gRu xubw== 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=5EqfuSfkxsIBcIYcNdH3MTgIH0PebJVb3pPhyU4KjH4=; b=PaXqOPiu6hDElCiu8a423a2q7ELkuutngEdRMBBXoWacZunUbsw3ANNT7Uzn3GD0h2 HfKRH29NMSLQaspABPrOLNUzl/RDISigpXwAPwUGggbeKDLhq8OIEd4qNwY8FzgGJobN 51ZgcqyNvUBCZPtfquojQiURVxKM96erzUvVJiw7tX5QxDPv6FkeWEWNF4YfBhzTi3k6 QD4oHbRg4FlK9IqTLZ2n8HWqKh6+yXgxxp/Pz8VBSkEeWHoM9rC9I+CaCx0kwFUKCTR5 iJtMXI7o2VynZwrZB/YBFzQ+1//9SzPli7gw9rkcch/u0q9e8S0QnH7ik8D3kqt4ibIg 71dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MObADnTD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id s17si17231732pfu.330.2022.02.09.03.00.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 03:00:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MObADnTD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 48E7AE0C3F1D; Wed, 9 Feb 2022 01:30:18 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385148AbiBGLbP (ORCPT + 99 others); Mon, 7 Feb 2022 06:31:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382775AbiBGLUs (ORCPT ); Mon, 7 Feb 2022 06:20:48 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B27E9C03FEDA; Mon, 7 Feb 2022 03:20:33 -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 7164661467; Mon, 7 Feb 2022 11:20:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50128C004E1; Mon, 7 Feb 2022 11:20:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644232823; bh=oKV/0tUCmzuCQDKEZ9sUtaQfHusBkRgbX5Iepng1Hp8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MObADnTDZ0yQm5kNtrhI4H8iMoxUaKBBXfqAaf4C77YaD+Z5YMwWLU3wSyQY9ZzzA wok7HkKoh7hvVseBHKh5aaLKc5pN/3cifYNhdmSpjpaFAn8Dpzhrrsqny26BdHMKQV 636l1q/0MynfDk6HY9bi2bgpDFTLpm/ZZ+qFlas4= 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.4 36/44] pinctrl: bcm2835: Fix a few error paths Date: Mon, 7 Feb 2022 12:06:52 +0100 Message-Id: <20220207103754.331444864@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103753.155627314@linuxfoundation.org> References: <20220207103753.155627314@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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 @@ -1261,16 +1261,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; + } } /* @@ -1294,8 +1296,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); @@ -1314,11 +1318,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 = {