From: Dan Carpenter <dan.carpenter@linaro.org>
To: Peng Fan <peng.fan@nxp.com>
Cc: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>,
Sudeep Holla <sudeep.holla@arm.com>,
Cristian Marussi <cristian.marussi@arm.com>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
Oleksii Moisieiev <oleksii_moisieiev@epam.com>,
Linus Walleij <linus.walleij@linaro.org>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
dl-linux-imx <linux-imx@nxp.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>
Subject: Re: [PATCH v5 4/4] pinctrl: Implementation of the generic scmi-pinctrl driver
Date: Fri, 15 Mar 2024 09:24:02 +0300 [thread overview]
Message-ID: <64523bd3-d208-4989-b8d9-57952c77954c@moroto.mountain> (raw)
In-Reply-To: <DU0PR04MB9417F0C53A0B112E7A8A334288282@DU0PR04MB9417.eurprd04.prod.outlook.com>
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
next prev parent reply other threads:[~2024-03-15 6:24 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-14 13:35 [PATCH v5 0/4] firmware: arm_scmi: Add SCMI v3.2 pincontrol protocol basic support Peng Fan (OSS)
2024-03-14 13:35 ` [PATCH v5 1/4] firmware: arm_scmi: introduce helper get_max_msg_size Peng Fan (OSS)
2024-03-14 13:35 ` [PATCH v5 2/4] dt-bindings: firmware: arm,scmi: support pinctrl protocol Peng Fan (OSS)
2024-03-14 15:32 ` Dan Carpenter
2024-03-14 13:35 ` [PATCH v5 3/4] firmware: arm_scmi: Add SCMI v3.2 pincontrol protocol basic support Peng Fan (OSS)
2024-03-15 16:58 ` Cristian Marussi
2024-03-21 14:46 ` Dan Carpenter
2024-03-24 10:45 ` Dan Carpenter
2024-03-24 12:15 ` Peng Fan
2024-03-14 13:35 ` [PATCH v5 4/4] pinctrl: Implementation of the generic scmi-pinctrl driver Peng Fan (OSS)
2024-03-14 15:31 ` Dan Carpenter
2024-03-15 0:44 ` Peng Fan
2024-03-15 6:24 ` Dan Carpenter [this message]
2024-03-20 9:53 ` Dan Carpenter
2024-03-14 16:48 ` [PATCH v5 0/4] firmware: arm_scmi: Add SCMI v3.2 pincontrol protocol basic support Cristian Marussi
2024-03-15 0:31 ` Peng Fan
2024-03-15 16:53 ` Cristian Marussi
2024-03-15 18:20 ` Dan Carpenter
2024-03-17 19:08 ` Cristian Marussi
2024-03-18 2:47 ` Peng Fan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=64523bd3-d208-4989-b8d9-57952c77954c@moroto.mountain \
--to=dan.carpenter@linaro.org \
--cc=conor+dt@kernel.org \
--cc=cristian.marussi@arm.com \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=kernel@pengutronix.de \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleksii_moisieiev@epam.com \
--cc=peng.fan@nxp.com \
--cc=peng.fan@oss.nxp.com \
--cc=robh+dt@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=sudeep.holla@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox