[PATCH v1 5/8] ACPI: x86: use acpi_dev_uid_match() for matching _UID

Raag Jadav posted 8 patches 2 years, 1 month ago
There is a newer version of this series
[PATCH v1 5/8] ACPI: x86: use acpi_dev_uid_match() for matching _UID
Posted by Raag Jadav 2 years, 1 month ago
Convert manual _UID references to use standard ACPI helpers.

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
 drivers/acpi/x86/utils.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/acpi/x86/utils.c b/drivers/acpi/x86/utils.c
index 63d834dd3811..bc65ebfcdf76 100644
--- a/drivers/acpi/x86/utils.c
+++ b/drivers/acpi/x86/utils.c
@@ -184,8 +184,7 @@ bool acpi_device_override_status(struct acpi_device *adev, unsigned long long *s
 			if (acpi_match_device_ids(adev, override_status_ids[i].hid))
 				continue;
 
-			if (!adev->pnp.unique_id ||
-			    strcmp(adev->pnp.unique_id, override_status_ids[i].uid))
+			if (!acpi_dev_uid_match(adev, override_status_ids[i].uid))
 				continue;
 		}
 
-- 
2.17.1
Re: [PATCH v1 5/8] ACPI: x86: use acpi_dev_uid_match() for matching _UID
Posted by Andy Shevchenko 2 years, 1 month ago
On Fri, Oct 20, 2023 at 02:17:29PM +0530, Raag Jadav wrote:
> Convert manual _UID references to use standard ACPI helpers.

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

...

> -			if (!adev->pnp.unique_id ||
> -			    strcmp(adev->pnp.unique_id, override_status_ids[i].uid))
> +			if (!acpi_dev_uid_match(adev, override_status_ids[i].uid))

The check for NULL argument inside that API does not affect the behaviour as
otherwise it will be a crash with the current implementation.

>  				continue;


-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v1 5/8] ACPI: x86: use acpi_dev_uid_match() for matching _UID
Posted by Rafael J. Wysocki 2 years, 1 month ago
On Fri, Oct 20, 2023 at 12:38 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Fri, Oct 20, 2023 at 02:17:29PM +0530, Raag Jadav wrote:
> > Convert manual _UID references to use standard ACPI helpers.
>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> ...
>
> > -                     if (!adev->pnp.unique_id ||
> > -                         strcmp(adev->pnp.unique_id, override_status_ids[i].uid))
> > +                     if (!acpi_dev_uid_match(adev, override_status_ids[i].uid))
>
> The check for NULL argument inside that API does not affect the behaviour as
> otherwise it will be a crash with the current implementation.

What current implementation do you mean, exactly?
Re: [PATCH v1 5/8] ACPI: x86: use acpi_dev_uid_match() for matching _UID
Posted by Andy Shevchenko 2 years, 1 month ago
On Fri, Oct 20, 2023 at 07:05:37PM +0200, Rafael J. Wysocki wrote:
> On Fri, Oct 20, 2023 at 12:38 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> > On Fri, Oct 20, 2023 at 02:17:29PM +0530, Raag Jadav wrote:

...

> > > -                     if (!adev->pnp.unique_id ||
> > > -                         strcmp(adev->pnp.unique_id, override_status_ids[i].uid))
> > > +                     if (!acpi_dev_uid_match(adev, override_status_ids[i].uid))
> >
> > The check for NULL argument inside that API does not affect the behaviour as
> > otherwise it will be a crash with the current implementation.
> 
> What current implementation do you mean, exactly?

strcmp() against NULL will crash the system.

-- 
With Best Regards,
Andy Shevchenko