From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28A94C433F5 for ; Fri, 28 Jan 2022 16:28:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232174AbiA1Q2F (ORCPT ); Fri, 28 Jan 2022 11:28:05 -0500 Received: from mga05.intel.com ([192.55.52.43]:9372 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231221AbiA1Q2F (ORCPT ); Fri, 28 Jan 2022 11:28:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643387285; x=1674923285; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=iDEdIyx/eA82CyxCDokO/3tZLh4lgebJYwjeiPMLUqE=; b=QoKMLjxhxXAMPvweGpnCH4NYh9N5pTf4F4EMdUmYjLjmLtVIh4DzePIC fl1uJXW7a0MpZpqnPVGB2gH3XizTgG9NRWNT2nxhfxDo3Ns+XysQJ4ubd 1HWS8nO82OI0MjL0t/YYFLjj/touNqPM29WTvMKHSTl1uPVI+j0Ws6mnM 8wShmmSlJus/wdHghdMr9DPX3UL6paQIMz16j+8vPx+j4cfGR/iFTV7g1 aYBd22JnmMFDCAtXldPJCNQjhT9ie3lsYqk6kcRoQMQ23g7/LjZWg+mp1 pRwyo45l9dqkFDp4gzHog+gJvdDzxx7KoC0B39X06hu1EUMiqgDNBvHIq A==; X-IronPort-AV: E=McAfee;i="6200,9189,10240"; a="333502956" X-IronPort-AV: E=Sophos;i="5.88,324,1635231600"; d="scan'208";a="333502956" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jan 2022 08:28:05 -0800 X-IronPort-AV: E=Sophos;i="5.88,324,1635231600"; d="scan'208";a="480790453" Received: from smile.fi.intel.com ([10.237.72.61]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jan 2022 08:28:01 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.95) (envelope-from ) id 1nDU5P-00FTd6-Vl; Fri, 28 Jan 2022 18:26:55 +0200 Date: Fri, 28 Jan 2022 18:26:55 +0200 From: Andy Shevchenko To: Florian Fainelli Cc: linux-kernel@vger.kernel.org, Linus Walleij , Ray Jui , Scott Branden , "maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE..." , Nicolas Saenz Julienne , Phil Elwell , Krzysztof Kozlowski , Hans Verkuil , Jason Wang , Marc Zyngier , "open list:PIN CONTROL SUBSYSTEM" , "moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE" , "moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE" Subject: Re: [PATCH] pinctrl: bcm2835: Fix a few error paths Message-ID: References: <20220127215033.267227-1-f.fainelli@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org On Fri, Jan 28, 2022 at 08:12:02AM -0800, Florian Fainelli wrote: > On 1/28/2022 6:35 AM, Andy Shevchenko wrote: > > On Thu, Jan 27, 2022 at 01:50:31PM -0800, Florian Fainelli wrote: > > > 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. > > > > > 1 file changed, 15 insertions(+), 8 deletions(-) > > > > While this seems legit per se, my eyes caught this: > > > > > > > if (!girq->parents) { > > > - pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range); > > > - return -ENOMEM; > > > + err = -ENOMEM; > > > + goto out_remove; > > > > Non-devm.... > > > > > } > > > if (is_7211) { > > > pc->wake_irq = devm_kcalloc(dev, BCM2835_NUM_IRQS, > > > sizeof(*pc->wake_irq), > > > GFP_KERNEL); > > > > ...followed by devm. > > > > It means more ordering bugs in the ->remove() and error path are lurking > > around. Can you double check and be sure that we do not have a case where > > non-devm registration code followed by devm? > > It seems to me like we are fine with the patch as is, because: > > - girq->parents is allocated with devm > - pc->wake_irq is allocated with devm > - name is allocated with devm > > and those are the only variables being allocated for which we also process > an error handling path. Okay, thanks. My worries that it might be the case when the GPIO ranges have been removed by explicit call in ->remove() followed by some interrupt or so and oops or misbehaviour because of that. -- With Best Regards, Andy Shevchenko From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D03B5C433EF for ; Fri, 28 Jan 2022 16:29:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=V8gpm2j+Jb/4LRNXa2juHfJane3zvtbxoW5Q9avx4ds=; b=GAGLVPBIv6FMk0 p/vO7sjZHbEmX/tVjXl7enBYEOJGK8472MjznDtO1Oksb3T5XlXaHW3Tk0EDv0+Nt5px6vJcqNSmZ AIPm59eQCMKPcbIIhGB4duA+PLOQ/U0q6atw0Iw3ULvfce3x6ybKw8uhiwoPy0ZRbs7geNyj9ZE/O uh8KOyTfqrgC34FY5rziQmTJv/upNhiYA3IboE4bS1hBC5G1QnavGfZRXIxQPAosJuk7C0LhxWfFg BjamXYRwl3CjnjWYIuJchUhN3VKSpK8CAgW+1fpJkxpDPiC+hFO6RfSbkjU+Mac70C44M01VkWWe1 XA0IrCAp339Ir5BC95RQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nDU6l-002zR8-9O; Fri, 28 Jan 2022 16:28:19 +0000 Received: from mga05.intel.com ([192.55.52.43]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nDU6Y-002zOs-IQ; Fri, 28 Jan 2022 16:28:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643387286; x=1674923286; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=iDEdIyx/eA82CyxCDokO/3tZLh4lgebJYwjeiPMLUqE=; b=G1VHjX3r8VmovqgHhOU/O6ymCcLdTklMuuISqV5S0N7cPk81Wu+aho0t BLy2rJ+iu1hwl2fQP0iL8HSTFvtNdBsqDN8TadffJ5L1aMVA6jLLqKhRT zJC2tTce8o8KKIMZNGGT7saW9alGQq2GQ+EGyCtKstIlotSgRrX0FwFX4 RJIaTAjt3QfckYHxpZNBtXA0+a29i2CkoDtpjnUAT/eTRE73O3DJOTFY1 NoLLpU3o3oztppZpJY9etw6hqvPQFEvf6NmrG4Mzn9PJIIixmftnXfxEC o+ixq/DQx9tITf6oOEGIo/4kVkn0JrvwDQ8lLO5S9PWXsElUL4UTHYrss A==; X-IronPort-AV: E=McAfee;i="6200,9189,10240"; a="333502957" X-IronPort-AV: E=Sophos;i="5.88,324,1635231600"; d="scan'208";a="333502957" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jan 2022 08:28:05 -0800 X-IronPort-AV: E=Sophos;i="5.88,324,1635231600"; d="scan'208";a="480790453" Received: from smile.fi.intel.com ([10.237.72.61]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jan 2022 08:28:01 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.95) (envelope-from ) id 1nDU5P-00FTd6-Vl; Fri, 28 Jan 2022 18:26:55 +0200 Date: Fri, 28 Jan 2022 18:26:55 +0200 From: Andy Shevchenko To: Florian Fainelli Cc: linux-kernel@vger.kernel.org, Linus Walleij , Ray Jui , Scott Branden , "maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE..." , Nicolas Saenz Julienne , Phil Elwell , Krzysztof Kozlowski , Hans Verkuil , Jason Wang , Marc Zyngier , "open list:PIN CONTROL SUBSYSTEM" , "moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE" , "moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE" Subject: Re: [PATCH] pinctrl: bcm2835: Fix a few error paths Message-ID: References: <20220127215033.267227-1-f.fainelli@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220128_082806_691107_5C0DB92D X-CRM114-Status: GOOD ( 21.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Jan 28, 2022 at 08:12:02AM -0800, Florian Fainelli wrote: > On 1/28/2022 6:35 AM, Andy Shevchenko wrote: > > On Thu, Jan 27, 2022 at 01:50:31PM -0800, Florian Fainelli wrote: > > > 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. > > > > > 1 file changed, 15 insertions(+), 8 deletions(-) > > > > While this seems legit per se, my eyes caught this: > > > > > > > if (!girq->parents) { > > > - pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range); > > > - return -ENOMEM; > > > + err = -ENOMEM; > > > + goto out_remove; > > > > Non-devm.... > > > > > } > > > if (is_7211) { > > > pc->wake_irq = devm_kcalloc(dev, BCM2835_NUM_IRQS, > > > sizeof(*pc->wake_irq), > > > GFP_KERNEL); > > > > ...followed by devm. > > > > It means more ordering bugs in the ->remove() and error path are lurking > > around. Can you double check and be sure that we do not have a case where > > non-devm registration code followed by devm? > > It seems to me like we are fine with the patch as is, because: > > - girq->parents is allocated with devm > - pc->wake_irq is allocated with devm > - name is allocated with devm > > and those are the only variables being allocated for which we also process > an error handling path. Okay, thanks. My worries that it might be the case when the GPIO ranges have been removed by explicit call in ->remove() followed by some interrupt or so and oops or misbehaviour because of that. -- With Best Regards, Andy Shevchenko _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel