Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2099922lqz; Tue, 2 Apr 2024 07:17:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXJEcm+8uulYFGJOqYiZhrKLbJ1jybyr6SPBWdUTBfEE45QnqDanX5lw63eaLji9XGT2g+7uoFduY4+9fyIL2vHuUJ8r+tNHt5bY640hQ== X-Google-Smtp-Source: AGHT+IGekvypqYv+u+6dQRuA0gL2ECrf8jCDl0dGPQYv93CoLsBEe8aomvjraxSabfuoS1ndynzH X-Received: by 2002:a05:6402:34c5:b0:56d:c91c:dfc2 with SMTP id w5-20020a05640234c500b0056dc91cdfc2mr5865992edc.31.1712067446251; Tue, 02 Apr 2024 07:17:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712067446; cv=pass; d=google.com; s=arc-20160816; b=EPzQMHBBQXCOR4ibO3lIVWyG1EJRAMYh2JJqApx3mHML6jn8K6MYr8pmvZVJL013AO APr+miodOfuQB6XrR/Orc+ih59RBCEuzmRdzOv+RdXc9J/xZdg8crNhbsMUg/eQFzRln /bcws7pRf0xlvFjsRhY5rHYYM6z6ZTFlhbLvlOnTCT83co0cTpldnZz8KVJJaqAmYv7y fFC3Kn1EMdiKomdFSHR70QI09dUpG1QIxNiowUUOCityf64/6eLnMm91od6q1E7aNEHA erK5urGfUUBXiJD1VbRy23dpXoW+xeJUUpIjc77OAg2g7W1lBWe8BeNftdCWDd4NeKwM iQ8Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Pd+8DVN5G2IkVOB54fyerdrNg9YmjMKBL8xpHTKHGmI=; fh=L4wPZ4JzgxmnF0DdwGmOqpH4zDKOkPkTAOn9TH3Mkq0=; b=FGd3liCfYjLkYFwd6bgBFbzeLAdJJnnKEozPthj2SO1mj3OQSKWls0Gck3+ufgBEM4 kK3hREEydBAB/gcUrr3df+tnxbA8F6MnsDZyXrA6f7hjZnJ1RmuFZfGUMTbS2Cked3YL l4DpBYTO/8r3SVJLyuqVbhUwFfyO3SU4PGrzB4LDi0/a15aksD7IMzx418SSwf5rt1B6 40VcuvgsB96u91oWMiqSDxDnak+yDJKO2zUVwf6H6xlSVOYWdTjfBxBXtfs/sZCQJeNH llU1weF48hcwQtupkCgflxjOQXnRTlDreXLaqISq5DlZnP51HiqI0jJXrKZONJ8wG+LP aNvg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OY3OBIdS; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-128109-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128109-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ek15-20020a056402370f00b0056be397b8d4si6042576edb.433.2024.04.02.07.17.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 07:17:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-128109-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OY3OBIdS; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-128109-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128109-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D3B3E1F26941 for ; Tue, 2 Apr 2024 14:10:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A1E0A85C46; Tue, 2 Apr 2024 14:09:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OY3OBIdS" Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE32985C4E for ; Tue, 2 Apr 2024 14:09:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712066982; cv=none; b=io30CXnfnbYOe88U7BkldSVz8fxYuR9JwUv5BU+/CW7g0FVZJwt+4M85/JlPrHieYOPXH04gVddNrZBF1zXkZfdJulp86uIFPzRk2l165z5igtAzSLu1mdRwblnw6c2udtrc2j87O5u6j9EbalXdPCVOvNBX9fJOnYkYu6GAwpY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712066982; c=relaxed/simple; bh=LTkw8G/UbnzbJ69YL6GosvdrYC0acddZdwlT7ImDQUo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jv/f/w5vMk12XelJpIMzP65DW6XXzXGJutVJsWv5bvPR5AQo+CJyYKRVNl/CbY6k0cGIs2iDX9P4LTPza+ltpH1hTafgGpNS7aCst736yKDEotsuY8hLl3csGJUxTuo9OKJ2pextfmwK7D0bbGAUWJWRIngjxOhc6LDik/Wbr60= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=OY3OBIdS; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a4e5ee91879so308391066b.3 for ; Tue, 02 Apr 2024 07:09:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712066979; x=1712671779; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Pd+8DVN5G2IkVOB54fyerdrNg9YmjMKBL8xpHTKHGmI=; b=OY3OBIdSWblv0nToz3q181O1+CbQTm6FF84pyqm1+qlq+GLigNp3vbYxsrKcY8PbaE HUgIX3/Hvue1FpHH+qAf2ULOCGgBBqbI6JUJhFLJN2aIhRua7nrFECSp9h0cfagTp7gz 7SOscx0ouyyzp24gon//1QVeB8L+s9o99V/r29hz4koQELs5EJtpG/j3zGxqYrp2ziJJ EbmNgOd2T/JeNwCMlm3o8kHHesf0uCuiSoNxnvnAA2sSODuQXXXOG4OFbcjRpSAvhW9U L9AhEBquNfemiOOOXU8mVTFjLDTJ352kw3Ul6row1abTE93QhH1m8jLm/fSK0x5lqZEl eZRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712066979; x=1712671779; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Pd+8DVN5G2IkVOB54fyerdrNg9YmjMKBL8xpHTKHGmI=; b=S1PMRI55BkbuuD82952Xv3f7U6qTOLqLVJcZojUyuGc4wvBwFFUAAnbN9HigrYKQ8J vFObunUp/v2CWGmZ7xwJAaP883P7AsjFuuHFPAMKMUgna57Tbn9TQJ9nyejqVI8zfNuH I81osFzEgJnBjYQn5KqN/Pz2D0pooSmGuVHqXS3dQoxJKVKl54JrF1KfJNn9WldSPF/p qx1Pw+5I7NFMso+I29kbxrV25e1Urto1ljeF210wzp5HDGn1xE1XMUvw1lgumTD6TSgO fUA2WxWwXZfZb/l9Mu8bO5lGOhEtIZPZ2L+mhPNy+q5hIGcS8nBJzvmeRhovqeAZH7bD hfkg== X-Forwarded-Encrypted: i=1; AJvYcCXnNZpmcCAuLYLwt4xqGl/XLp/WF3CeIhuEbAMS0mMGGGC4z8WHOZLxuCFAjRbsxvgQCYCYCgOScBcGw/MT4zVLAwx2/TZn98xCwZMd X-Gm-Message-State: AOJu0Yx5O27Btg6igUBbRlre28aP/6hbwjO/RIrH6TSyoo1nnCd/gF4F ZqPcMo68zHVo1Dq282bUdODmCPO7gslaXB7fLtW4e9idSGnqowHfpN3L8j3LcNs= X-Received: by 2002:a17:907:7f12:b0:a4e:516b:2fea with SMTP id qf18-20020a1709077f1200b00a4e516b2feamr6665482ejc.50.1712066978929; Tue, 02 Apr 2024 07:09:38 -0700 (PDT) Received: from localhost ([102.222.70.76]) by smtp.gmail.com with ESMTPSA id q2-20020a170906b28200b00a4655976025sm6534890ejz.82.2024.04.02.07.09.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 07:09:38 -0700 (PDT) Date: Tue, 2 Apr 2024 17:09:34 +0300 From: Dan Carpenter To: Andy Shevchenko Cc: "Peng Fan (OSS)" , Sudeep Holla , Cristian Marussi , 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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? It's nice to be able to allocate zero element arrays and generally it works well in the kernel. The one common bug with zero element arrays has to do with strings. Something like this (garbage) example: str = kmalloc(n_char, GFP_KERNEL); copy_from_user(str, user_ptr, n_char); str[n_char - 1] = '\0'; If the str is zero bytes long it will lead to an Oops when we add a NUL terminator. regards, dan carpenter