Re: [PATCH 5/6] gpiolib: consolidate GPIO lookups

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

 



On Fri, Nov 04, 2022 at 09:56:57PM -0700, Dmitry Torokhov wrote:
> On Fri, Nov 04, 2022 at 11:06:58PM +0200, Andy Shevchenko wrote:
> > On Fri, Nov 04, 2022 at 11:52:26AM -0700, Dmitry Torokhov wrote:
> > > On Fri, Nov 04, 2022 at 07:17:27PM +0200, Andy Shevchenko wrote:
> > > > On Thu, Nov 03, 2022 at 11:10:15PM -0700, Dmitry Torokhov wrote:

...

> > > > > +		desc = gpiod_find_by_fwnode(fwnode, consumer, con_id, idx,
> > > > > +					    &flags, &lookupflags);
> > 
> > Looking into drivers/base/property.c makes me realize that you might need to
> > test for error pointer as well.
> > 
> > Perhaps something like
> > 
> > 	if (IS_ERR_OR_NULL(fwnode))
> > 		return ERR_PTR(-ENOENT);
> > 
> > in the gpiod_find_by_fwnode() needs to be added. Can you check this?
> 
> No, only fwnode->secondary pointer can be PTR_ERR()-encoded.
> 
> From comment to set_primary_fwnode() in drivers/base/core.c
> 
>  * Valid fwnode cases are:
>  *  - primary --> secondary --> -ENODEV
>  *  - primary --> NULL
>  *  - secondary --> -ENODEV
>  *  - NULL
> 
> I do not believe we should be concerned about someone passing secondary
> pointers from fwnodes directly into gpiolib.

It's not only about secondary vs. primary notation, some of fwnode API calls
may return error pointer and hence entire stack should be prepared for that.

See 002752af7b89 ("device property: Allow error pointer to be passed to
fwnode APIs") as an example.

-- 
With Best Regards,
Andy Shevchenko





[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux