On Mon, Mar 07, 2022 at 04:15:23PM +0000, Sa, Nuno wrote: > > From: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> > > Sent: Friday, March 4, 2022 6:33 PM ... > > Some of the fwnode APIs might return an error pointer instead of > > NULL > > or valid fwnode handle. The result of such API call may be considered > > optional and hence the test for it is usually done in a form of > > > > fwnode = fwnode_find_reference(...); > > if (IS_ERR_OR_NULL(fwnode)) > > ...error handling... > > > > Nevertheless the resulting fwnode may have bumped reference count > > and > > hence caller of the above API is obliged to call fwnode_handle_put(). > > Since fwnode may be not valid either as NULL or error pointer the > > check > > has to be performed there. This approach uglifies the code and adds > > a point of making a mistake, i.e. forgetting about error point case. > > > > To prevent this allow error pointer to be passed to the fwnode APIs. ... > > v2: adjusted the entire fwnode API (Sakari) > > > > Nuno, can you test this with the ltc2983 series, including the > > IS_ERR_OR_NULL() > > fix to it? > > Hi Andy, > > Just tested this patch with the ltc2983 series and now > fwnode_handle_put() does not crash when fwnode is an > error pointer. I think this usecase does not cover all > of the patch so I'm not sure if a tested by tag here is > meaningful... I believe it still makes sense because we understand what you have tested. And at least it has some kind of BAT: - compile testing - testing (some of the) branches > If it is, go ahead: > > Tested-by: Nuno Sá <nuno.sa@xxxxxxxxxx> Thank you! I'll send v3 because I want to amend the commit message. -- With Best Regards, Andy Shevchenko