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 58BA6CD1284 for ; Tue, 2 Apr 2024 16:40:21 +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=In4IYfb5H52uDdQituqw4w7G22a0if6fdi0POzChliI=; b=sqKpNg7i/B1piz MyQDRc4GJgGNLj5gcVvGWzlzo4NePM5+X8gkTb/pc77YFlrUjsu2yr3jMQaDlgvW1BVB8Gvv7CPUY LoiInUUeax5QjuRD82T17hspTyt+NXzc7mpwU+zNSipFstamh8e/gyDMUdef2PU70qe79d1IFTxFb hPpr7IKUVWMzVYrYeGAdqljcOD2MPNTks8DQ+dcVfdp+WbhblGPITilZ6bm3KsciguFaxEyDrD11Q rzBGezu1w33CEzlOMgMBC9mbSIKg3dfGWa/a1pOG01XfVUt24hKMdl2ZazhDP11EDPiCeb7Ytq1y1 sd3Y+QEIi6UJKxb5ygqQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rrhBD-0000000C4Xn-3T43; Tue, 02 Apr 2024 16:40:11 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rrhBA-0000000C4WX-3ZfA for linux-arm-kernel@lists.infradead.org; Tue, 02 Apr 2024 16:40:10 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6375A1007; Tue, 2 Apr 2024 09:40:39 -0700 (PDT) Received: from pluto (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1D80C3F7B4; Tue, 2 Apr 2024 09:40:06 -0700 (PDT) Date: Tue, 2 Apr 2024 17:40:03 +0100 From: Cristian Marussi To: Dan Carpenter Cc: Andy Shevchenko , "Peng Fan (OSS)" , Sudeep Holla , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Linus Walleij , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, Peng Fan , Oleksii Moisieiev Subject: Re: [PATCH v7 4/4] pinctrl: Implementation of the generic scmi-pinctrl driver Message-ID: References: <20240402-pinctrl-scmi-v7-0-3ea519d12cf7@nxp.com> <20240402-pinctrl-scmi-v7-4-3ea519d12cf7@nxp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240402_094008_957212_32C8855C X-CRM114-Status: GOOD ( 16.22 ) 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 Tue, Apr 02, 2024 at 05:09:34PM +0300, Dan Carpenter wrote: > On Tue, Apr 02, 2024 at 04:22:45PM +0300, Andy Shevchenko wrote: > > On Tue, Apr 02, 2024 at 10:22:24AM +0800, Peng Fan (OSS) wrote: > > > +static int pinctrl_scmi_get_pins(struct scmi_pinctrl *pmx, > > > + struct pinctrl_desc *desc) > > > +{ > > > + struct pinctrl_pin_desc *pins; > > > + unsigned int npins; > > > + int ret, i; > > > + > > > + npins = pinctrl_ops->count_get(pmx->ph, PIN_TYPE); > > > + /* > > > + * npins will never be zero, the scmi pinctrl driver has bailed out > > > + * if npins is zero. > > > + */ > > > > This is fragile, but at least it is documented. > > > > It was never clear to me where the crash would happen if npins was zero. > Does some part of pinctrl internals assume we have at least one pin? Dont think there were any possible crashes since at the protoocl layer (not here) kcalloc returns ZERO_SIZE_PTR into pinfo->pins for a zero-bytes allocation BUT it is indeed never accessed since any attempt to access a pin will be considerd invalid (any u32 index >= (nr_pins=0))... ...but what is the point of loading protocol and drivers with zero pins ? You can have zero grouos and zero functions, but zero pins ? Thanks, Cristian _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel