Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp582726lqb; Thu, 14 Mar 2024 23:28:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWbbWHn+mbKVneLF7ML8uZXq35uZnhC1CbCGFhyClQhrfpHSFsC3435O0OBot+I2WtIAngiEyDUKgu++xDb7FT3zpEXPGbssDwSacwzRw== X-Google-Smtp-Source: AGHT+IGkbqifg13KroUNNqZmw7+3gIAm5dsR9VyM9HqfMnFhvW7RwCNkyrx8FFXcsQXGfTXAMkfM X-Received: by 2002:a05:6402:4491:b0:568:a30c:2db5 with SMTP id er17-20020a056402449100b00568a30c2db5mr1913927edb.40.1710484109082; Thu, 14 Mar 2024 23:28:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710484109; cv=pass; d=google.com; s=arc-20160816; b=MUWmtsM65/6g/0yYsuRILMi9Pedm//8fYgZ9EFzdfBaMTLeY9LnpDnZ09c2/nwmj0z dmI+YDSM+ftq5zQ6mMFhxCbK/wR8nJXgoZKq6W37FHizl8EbIJq992fPXdu8XHPpX+hC EIMVQcO4gTHr/Nh/h0Ix2IzxSIWXzq4dskpYSWLMlHE8o+PMIazPkhw+b3bIz6L/qOUi 4FkBKFzzuKaSI9ayLZDGm+KmxzU0UN8QQa0Dsoe2k15Ulvdfw1xtna5A1bkp6eZtwJBQ I5R5Y2w3arEYaiTdbkyKHDYzbnmQMKcEpsK0MpFU3u/4q3jByDOiKI8UfmcZP/9fIKPX eO3g== 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=s9LPhepAIkivg02JjKy3gGkvg0KX9KjTZMR9ul/pzXw=; fh=j4ydfmZaPQzWcwM+sa+0buX0YBgkgNQ5z1+Rpcl5j78=; b=QNQ9aNVa82+wAH2iSazxFv5Tg06YYPxNOKN6Myi1vBsHcyI6wIJWHpMH93g6NNj91e KwOAHngSi/bvo9Gfw7AYLnFKpjLRCu7Wkk49m1YfBQA7JtaS+2cfey+oAGkLVa63yLMg W/TMsIa4gmAAJHmKhZh3gURkxuhkIBhyxbqV2Z1ba3w1/GN54NX+Sk90dyroaPgX1cLD 4sJAT3drXn5vaUFev4yElefE7/jIw24thI5pJD803I5BbR5pGCnd2oL48A/Xazf7Ffpm yc6TKHI9X9zKG6OwtOC72VNgDHmwTMDdx7uH4seXB9tTY3p9ozSjvN4WDGwEWlT4/RKa RvVg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hi4E6Ocl; 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-104085-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104085-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 s20-20020a056402037400b005640d58d562si1476402edw.534.2024.03.14.23.28.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 23:28:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-104085-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=hi4E6Ocl; 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-104085-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104085-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 0C6CB1F22AF9 for ; Fri, 15 Mar 2024 06:28:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DFDA31429B; Fri, 15 Mar 2024 06:24:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hi4E6Ocl" Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 3C47614273 for ; Fri, 15 Mar 2024 06:24:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710483852; cv=none; b=CxjOPPsynFrQ903b+TmhDpth6yOoUy/H98MpZZ2yS0pF0+aozxFUxGWKRw7M2IMHt28/pqsBj78Pdr3n0Qocakt4qzKbINjI+d9mx7IlYGmC4f9E4SBW74HBZ5pYPVWMlfTsn5PNps4CfxypuRl63IpRuZiHRwQltuia1PM7+gc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710483852; c=relaxed/simple; bh=8hatKKv5/7R423aa6ntHditmiT/I4Zc0RS592ZzdzBo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pcGhGaYEfQngqmzwmMV2EgYtdc0Iisb79dVyzox9lk3cZ84jFhCU2fkJ1jOgH9UvISh0KPqXAcxa9oe/ZUV2oTKlGX5UBT7qIygWQKnAhUrySQq680ghur7Uf1F4DlbJ4Pjux2iF511LEa6BmJioTeADajNSL/JwfqQr5SRMS5o= 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=hi4E6Ocl; arc=none smtp.client-ip=209.85.128.43 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-wm1-f43.google.com with SMTP id 5b1f17b1804b1-413eee86528so11547785e9.3 for ; Thu, 14 Mar 2024 23:24:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710483847; x=1711088647; 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=s9LPhepAIkivg02JjKy3gGkvg0KX9KjTZMR9ul/pzXw=; b=hi4E6OclXfSNhOQsILaTH56uAg3eD5I+wY6oZTBCxOBnao3ofmJkn4TGM70t91fqXZ IJl/pdCOtoJRVidZt3/9fi4gQ5MhYBRz8KkDWrd1MSAZ77MI/D2034HKDNIMRf8tkCPs 2uQSurVlurkVAxHfwvs7iqEsmkGPibL0lTnKCFf+AeWd3lP4N2/Z9FUJoofN8oRJF0I2 lJBbfRQfgRZCcip6AKN+lXxjMCrG4SdDFuofFJD+ge+tuC1ZVDaAeQ8ZFFHt3rF+qJb5 /VfNbYAdmTN8GC63NhnSmF1ZYYn+BtAElEG19SpRxKfg8xH73jGN0IOdjblYI+6T44rp p/dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710483847; x=1711088647; 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=s9LPhepAIkivg02JjKy3gGkvg0KX9KjTZMR9ul/pzXw=; b=bD/KAaU2mnAx1EITzzkNH2XGRN9Oc6zOB5XpD5gl55wmZz+9ZGvOp3cCM2I/loK3lS UcjveOJxNoF0GPf3If660mra6dSaMXZx+yaLlJM30sYikoCII0FtFniC3KRlk50ibJlZ es1zJZW9M8yhI+yT8rQLKLQrk8SEQuAMSb1RJo8GYclxIjLMe2v2bemZ38p0YdDd5HJH nDI0ybUGjfc0AE8r9A1AR0YPuqKepJdqewpAUd4uFiUUVzIEiSyxzhrk/nwQ58S1aEuE hdYCR2TF2c254ES1criB07xG72YUG6DxwO9jHRDfx8/aJ8ithwhZ4Wx8E3LqCEn+PqRc CNsQ== X-Forwarded-Encrypted: i=1; AJvYcCXyttM8wCI/2y+wFM1QiJsn8tP9z8lLbKjr6ahyF8PZVz2SHbguUwm2nLOCqMcOiaJObYpnW4NQWipDH5wGd3V4RoBGOVEb6tWFN6ox X-Gm-Message-State: AOJu0YzN0NJe8PEr15aZ8f2RtcwQOrgyD8ODvP5PP4PGFaKYYZkTEIx7 E1hpU1z9GPUyOdnrG3E1bHZuxeThsI/v0HseDN/Ugj2cFl81XXAXSiiH2eD5D8Y= X-Received: by 2002:a05:6000:a90:b0:33e:4238:8615 with SMTP id dh16-20020a0560000a9000b0033e42388615mr2698769wrb.40.1710483847319; Thu, 14 Mar 2024 23:24:07 -0700 (PDT) Received: from localhost ([102.222.70.76]) by smtp.gmail.com with ESMTPSA id dd12-20020a0560001e8c00b0033eab3520a9sm2384912wrb.43.2024.03.14.23.24.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 23:24:06 -0700 (PDT) Date: Fri, 15 Mar 2024 09:24:02 +0300 From: Dan Carpenter To: Peng Fan Cc: "Peng Fan (OSS)" , Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Oleksii Moisieiev , Linus Walleij , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , dl-linux-imx , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-gpio@vger.kernel.org" Subject: Re: [PATCH v5 4/4] pinctrl: Implementation of the generic scmi-pinctrl driver Message-ID: <64523bd3-d208-4989-b8d9-57952c77954c@moroto.mountain> References: <20240314-pinctrl-scmi-v5-0-b19576e557f2@nxp.com> <20240314-pinctrl-scmi-v5-4-b19576e557f2@nxp.com> <55ec2392-c196-4669-a339-12ef336707fa@moroto.mountain> 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 Fri, Mar 15, 2024 at 12:44:34AM +0000, Peng Fan wrote: > > Subject: Re: [PATCH v5 4/4] pinctrl: Implementation of the generic scmi- > > pinctrl driver > > > > On Thu, Mar 14, 2024 at 09:35:21PM +0800, Peng Fan (OSS) wrote: > > > +static int pinctrl_scmi_get_function_groups(struct pinctrl_dev *pctldev, > > > + unsigned int selector, > > > + const char * const **groups, > > > + unsigned int * const num_groups) > > { > > > + const unsigned int *group_ids; > > > + int ret, i; > > > + struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev); > > > + > > > + if (!groups || !num_groups) > > > + return -EINVAL; > > > + > > > + if (selector < pmx->nr_functions && > > > + pmx->functions[selector].num_groups) { > > > > If pmx->functions[selector].num_groups is set then we assume that > > functions[selector].groups has been allocated. > > > > > + *groups = (const char * const *)pmx- > > >functions[selector].groups; > > > + *num_groups = pmx->functions[selector].num_groups; > > > + return 0; > > > + } > > > + > > > + ret = pinctrl_ops->function_groups_get(pmx->ph, selector, > > > + &pmx- > > >functions[selector].num_groups, > > > + &group_ids); > > > > However, pmx->functions[selector].num_groups is set here and not cleared > > on the error paths. Or instead of clearing the .num_groups it would be nice > > to pass a local variable and only do the > > pmx->functions[selector].num_groups = local assignment right before the > > success return. > > So you concern is I should clear the pmx->functions[selector].num_groups in > err path, right? > Yes. If functions[selector].groups is invalid (NULL or freed) then the pmx->functions[selector].num_groups variable must also be zero. regards, dan carpenter