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

Andy Shevchenko
2021-11-03T17:02:26Z

On Wed, Nov 03, 2021 at 03:34:04PM +0200, Sakari Ailus wrote:
> Check that the fwnode argument passed to acpi_fwnode_handle is non-NULL,

acpi_fwnode_handle()

> 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.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

> Cc: stable@vger.kernel.org # v5.15 and up
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
> 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)
> --
> 2.30.2
>
>

--
With Best Regards,
Andy Shevchenko