Re: [PATCH 1/3] ACPI: Make acpi_fwnode_handle safer

Sakari Ailus
2021-11-04T12:48:38Z

Hi Rafael,

On Wed, Nov 03, 2021 at 06:55:17PM +0100, Rafael J. Wysocki wrote:
> On Wed, Nov 3, 2021 at 2:33 PM Sakari Ailus
> <sakari.ailus@linux.intel.com> wrote:
> >
> > Check that the fwnode argument passed to acpi_fwnode_handle is non-NULL,
> > and return NULL if it is, otherwise the fwnode. Thus the caller doesn't
> > have to ensure the argument is a valid non-NULL fwnode.
> >
> > Cc: stable@vger.kernel.org # v5.15 and up
>
> Why?
>
> > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
>
> That's because you want to avoid a NULL check in the second patch and
> it adds a ton of redundant NULL checks all over the place.
>
> Like for example in include/acpi/acpi.h:
>
> #define ACPI_COMPANION_SET(dev, adev) set_primary_fwnode(dev, (adev) ? \
> acpi_fwnode_handle(adev) : NULL)
>
> You should at least get rid of this one.

That's a fair point.

acpi_fwnode_handle() doesn't have a tonne of users so it's entirely
feasible to change the users as necessary but in either case I guess I'll
drop this from stable as it's likely to conflict with some of these.

--
Regards,

Sakari Ailus