Re: [PATCH v3 3/3] iio: temperature: ltc2983: Make use of device properties

From: Andy Shevchenko
Date: Thu Mar 03 2022 - 09:24:31 EST


On Thu, Mar 03, 2022 at 01:31:56PM +0000, Sa, Nuno wrote:

...

> > + ref = fwnode_find_reference(child, "adi,cold-junction-
> > handle", 0);
> > + if (ref) {
>
> This is nok. It needs to be 'if (IS_ERR(ref))'. We then should return
> ERR_CAST() in case of errors inside the if block.

This is a good catch!

> As this reference
> is also optional, we need to nullify ref in case we don't find the
> it. Otherwise fwnode_handle_put() breaks.

No, this is not correct. fwnode_handle_put() is ERR_PTR aware.

> We also need to use ptr error logic in the other places where
> fwnode_find_reference() is used. Although, in the other cases
> the ref is mandatory, so there's no need to care with breaking
> fwnode_handle_put().
>
> After these changes (I think the changes are straight enough;
> but I can re-test if you or Jonathan ask for it):
>
> Tested-by: Nuno Sá <nuno.sa@xxxxxxxxxx>
>

--
With Best Regards,
Andy Shevchenko