Re: [PATCH v5 4/4] pinctrl: Implementation of the generic scmi-pinctrl driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux