Re: [PATCH v2 2/2] nvmem: core: Expose cells through sysfs

From: Greg Kroah-Hartman
Date: Thu Jun 01 2023 - 05:04:02 EST


On Thu, Jun 01, 2023 at 10:51:14AM +0200, Miquel Raynal wrote:
> > > + /* Without exposed cells, successfully exit after
> > > assigning an empty attributes array */
> > > + if (!ncells)
> > > + goto unlock_mutex;
> >
> > Shouldn't this check be higher up _before_ you allocate any memory?
> > If the attribute group list is empty, nothing should be created,
> > right? Or will the driver core crash?
>
> As you rightfully guessed it, the core will crash if no list is
> provided at all. I need to provide an empty list with just an empty
> member and everything goes smoothly.

Let's fix the core, it shouldn't crash like that :)

thanks,

greg k-h