lkml.org 
[lkml]   [2024]   [Apr]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v7 4/4] pinctrl: Implementation of the generic scmi-pinctrl driver
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

\
 
 \ /
  Last update: 2024-05-27 16:19    [W:1.291 / U:0.396 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site