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

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

 



On Wed, Nov 3, 2021 at 2:33 PM Sakari Ailus
<sakari.ailus@xxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxx # v5.15 and up

Why?

> Signed-off-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>

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.

> ---
>  include/acpi/acpi_bus.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
> index 53b6e9f9de7b4..c34d94521d40c 100644
> --- a/include/acpi/acpi_bus.h
> +++ b/include/acpi/acpi_bus.h
> @@ -445,7 +445,7 @@ static inline bool acpi_data_node_match(const struct fwnode_handle *fwnode,
>
>  static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev)
>  {
> -       return &adev->fwnode;
> +       return adev ? &adev->fwnode : NULL;
>  }
>
>  static inline void *acpi_driver_data(struct acpi_device *d)
> --



[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