All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] drivers/acpi/acpi_video: check return value of acpi_get_parent()
@ 2022-09-02  7:41 Li Zhong
  2022-09-10 16:17 ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Li Zhong @ 2022-09-02  7:41 UTC (permalink / raw)
  To: linux-acpi, linux-kernel; +Cc: rafael, Li Zhong

Check return status of acpi_get_parent() to confirm whether it fails.

Signed-off-by: Li Zhong <floridsleeves@gmail.com>
---
 drivers/acpi/acpi_video.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index 5cbe2196176d..5fca9a39b1a4 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
+	// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  *  video.c - ACPI Video Driver
  *
@@ -1753,6 +1753,7 @@ static void acpi_video_dev_register_backlight(struct acpi_video_device *device)
 	int result;
 	static int count;
 	char *name;
+	acpi_status status;
 
 	result = acpi_video_init_brightness(device);
 	if (result)
@@ -1766,8 +1767,9 @@ static void acpi_video_dev_register_backlight(struct acpi_video_device *device)
 		return;
 	count++;
 
-	acpi_get_parent(device->dev->handle, &acpi_parent);
-
+	status = acpi_get_parent(device->dev->handle, &acpi_parent);
+	if (ACPI_FAILURE(status))
+		return;
 	pdev = acpi_get_pci_dev(acpi_parent);
 	if (pdev) {
 		parent = &pdev->dev;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] drivers/acpi/acpi_video: check return value of acpi_get_parent()
  2022-09-02  7:41 [PATCH v1] drivers/acpi/acpi_video: check return value of acpi_get_parent() Li Zhong
@ 2022-09-10 16:17 ` Rafael J. Wysocki
  2022-09-17  1:25   ` Li Zhong
  0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2022-09-10 16:17 UTC (permalink / raw)
  To: Li Zhong
  Cc: ACPI Devel Maling List, Linux Kernel Mailing List, Rafael J. Wysocki

On Fri, Sep 2, 2022 at 9:42 AM Li Zhong <floridsleeves@gmail.com> wrote:
>
> Check return status of acpi_get_parent() to confirm whether it fails.
>
> Signed-off-by: Li Zhong <floridsleeves@gmail.com>
> ---
>  drivers/acpi/acpi_video.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
> index 5cbe2196176d..5fca9a39b1a4 100644
> --- a/drivers/acpi/acpi_video.c
> +++ b/drivers/acpi/acpi_video.c
> @@ -1,4 +1,4 @@
> -// SPDX-License-Identifier: GPL-2.0-or-later
> +       // SPDX-License-Identifier: GPL-2.0-or-later

This change surely is not intended?

>  /*
>   *  video.c - ACPI Video Driver
>   *
> @@ -1753,6 +1753,7 @@ static void acpi_video_dev_register_backlight(struct acpi_video_device *device)
>         int result;
>         static int count;
>         char *name;
> +       acpi_status status;
>
>         result = acpi_video_init_brightness(device);
>         if (result)
> @@ -1766,8 +1767,9 @@ static void acpi_video_dev_register_backlight(struct acpi_video_device *device)
>                 return;
>         count++;
>
> -       acpi_get_parent(device->dev->handle, &acpi_parent);
> -
> +       status = acpi_get_parent(device->dev->handle, &acpi_parent);
> +       if (ACPI_FAILURE(status))
> +               return;

But device->dev->handle is known to be valid, so the only case in
which acpi_get_parent() above can fail is when the given namespace
object has no parent, in which case acpi_parent will be NULL, so that
should be caught my the check below, shouldn't it?

>         pdev = acpi_get_pci_dev(acpi_parent);
>         if (pdev) {
>                 parent = &pdev->dev;
> --

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] drivers/acpi/acpi_video: check return value of acpi_get_parent()
  2022-09-10 16:17 ` Rafael J. Wysocki
@ 2022-09-17  1:25   ` Li Zhong
  0 siblings, 0 replies; 3+ messages in thread
From: Li Zhong @ 2022-09-17  1:25 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: ACPI Devel Maling List, Linux Kernel Mailing List

On Sat, Sep 10, 2022 at 9:17 AM Rafael J. Wysocki <rafael@kernel.org> wrote:
>
> On Fri, Sep 2, 2022 at 9:42 AM Li Zhong <floridsleeves@gmail.com> wrote:
> >
> > Check return status of acpi_get_parent() to confirm whether it fails.
> >
> > Signed-off-by: Li Zhong <floridsleeves@gmail.com>
> > ---
> >  drivers/acpi/acpi_video.c | 8 +++++---
> >  1 file changed, 5 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
> > index 5cbe2196176d..5fca9a39b1a4 100644
> > --- a/drivers/acpi/acpi_video.c
> > +++ b/drivers/acpi/acpi_video.c
> > @@ -1,4 +1,4 @@
> > -// SPDX-License-Identifier: GPL-2.0-or-later
> > +       // SPDX-License-Identifier: GPL-2.0-or-later
>
> This change surely is not intended?
>
> >  /*
> >   *  video.c - ACPI Video Driver
> >   *
> > @@ -1753,6 +1753,7 @@ static void acpi_video_dev_register_backlight(struct acpi_video_device *device)
> >         int result;
> >         static int count;
> >         char *name;
> > +       acpi_status status;
> >
> >         result = acpi_video_init_brightness(device);
> >         if (result)
> > @@ -1766,8 +1767,9 @@ static void acpi_video_dev_register_backlight(struct acpi_video_device *device)
> >                 return;
> >         count++;
> >
> > -       acpi_get_parent(device->dev->handle, &acpi_parent);
> > -
> > +       status = acpi_get_parent(device->dev->handle, &acpi_parent);
> > +       if (ACPI_FAILURE(status))
> > +               return;
>
> But device->dev->handle is known to be valid, so the only case in
> which acpi_get_parent() above can fail is when the given namespace
> object has no parent, in which case acpi_parent will be NULL, so that
> should be caught my the check below, shouldn't it?
>
> >         pdev = acpi_get_pci_dev(acpi_parent);
> >         if (pdev) {
> >                 parent = &pdev->dev;
> > --

That makes sense. Thank you!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-09-17  1:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-02  7:41 [PATCH v1] drivers/acpi/acpi_video: check return value of acpi_get_parent() Li Zhong
2022-09-10 16:17 ` Rafael J. Wysocki
2022-09-17  1:25   ` Li Zhong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.