All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ACPI: LPSS: Fix missing check in register_device_clock
@ 2022-06-23 13:21 huhai
  2022-06-23 13:25 ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: huhai @ 2022-06-23 13:21 UTC (permalink / raw)
  To: rafael, lenb; +Cc: linux-acpi, linux-kernel, huhai

From: huhai <huhai@kylinos.cn>

register_device_clock() misses a check for platform_device_register_simple().
Add a check to fix it.

Signed-off-by: huhai <huhai@kylinos.cn>
---
 drivers/acpi/acpi_lpss.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index fbe0756259c5..c4d4d21391d7 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -422,6 +422,9 @@ static int register_device_clock(struct acpi_device *adev,
 	if (!lpss_clk_dev)
 		lpt_register_clock_device();
 
+	if (IS_ERR(lpss_clk_dev))
+		return PTR_ERR(lpss_clk_dev);
+
 	clk_data = platform_get_drvdata(lpss_clk_dev);
 	if (!clk_data)
 		return -ENODEV;
-- 
2.27.0


No virus found
		Checked by Hillstone Network AntiVirus


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

* Re: [PATCH] ACPI: LPSS: Fix missing check in register_device_clock
  2022-06-23 13:21 [PATCH] ACPI: LPSS: Fix missing check in register_device_clock huhai
@ 2022-06-23 13:25 ` Rafael J. Wysocki
  2022-06-24  2:20   ` huhai
  0 siblings, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2022-06-23 13:25 UTC (permalink / raw)
  To: huhai
  Cc: Rafael J. Wysocki, Len Brown, ACPI Devel Maling List,
	Linux Kernel Mailing List, huhai

On Thu, Jun 23, 2022 at 3:21 PM huhai <15815827059@163.com> wrote:
>
> From: huhai <huhai@kylinos.cn>
>
> register_device_clock() misses a check for platform_device_register_simple().
> Add a check to fix it.
>
> Signed-off-by: huhai <huhai@kylinos.cn>
> ---
>  drivers/acpi/acpi_lpss.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
> index fbe0756259c5..c4d4d21391d7 100644
> --- a/drivers/acpi/acpi_lpss.c
> +++ b/drivers/acpi/acpi_lpss.c
> @@ -422,6 +422,9 @@ static int register_device_clock(struct acpi_device *adev,
>         if (!lpss_clk_dev)
>                 lpt_register_clock_device();
>
> +       if (IS_ERR(lpss_clk_dev))
> +               return PTR_ERR(lpss_clk_dev);
> +

Why not use IS_ERR_OR_NULL() instead?

>         clk_data = platform_get_drvdata(lpss_clk_dev);
>         if (!clk_data)
>                 return -ENODEV;
> --
> 2.27.0
>
>
> No virus found
>                 Checked by Hillstone Network AntiVirus
>

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

* Re:Re: [PATCH] ACPI: LPSS: Fix missing check in register_device_clock
  2022-06-23 13:25 ` Rafael J. Wysocki
@ 2022-06-24  2:20   ` huhai
  2022-06-29 18:20     ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: huhai @ 2022-06-24  2:20 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Len Brown, ACPI Devel Maling List, Linux Kernel Mailing List, huhai


At 2022-06-23 21:25:55, "Rafael J. Wysocki" <rafael@kernel.org> wrote:
>On Thu, Jun 23, 2022 at 3:21 PM huhai <15815827059@163.com> wrote:
>>
>> From: huhai <huhai@kylinos.cn>
>>
>> register_device_clock() misses a check for platform_device_register_simple().
>> Add a check to fix it.
>>
>> Signed-off-by: huhai <huhai@kylinos.cn>
>> ---
>>  drivers/acpi/acpi_lpss.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
>> index fbe0756259c5..c4d4d21391d7 100644
>> --- a/drivers/acpi/acpi_lpss.c
>> +++ b/drivers/acpi/acpi_lpss.c
>> @@ -422,6 +422,9 @@ static int register_device_clock(struct acpi_device *adev,
>>         if (!lpss_clk_dev)
>>                 lpt_register_clock_device();
>>
>> +       if (IS_ERR(lpss_clk_dev))
>> +               return PTR_ERR(lpss_clk_dev);
>> +
>
>Why not use IS_ERR_OR_NULL() instead?

platform_device_register_simple() never returns NULL as it declared bellowing,
so use IS_ERR() to validate the return value should be enough.

/**
 * platform_device_register_simple - add a platform-level device and its resources
 * ...
 * Returns &struct platform_device pointer on success, or ERR_PTR() on error.
 */

Thanks.

>
>>         clk_data = platform_get_drvdata(lpss_clk_dev);
>>         if (!clk_data)
>>                 return -ENODEV;
>> --
>> 2.27.0
>>
>>
>> No virus found
>>                 Checked by Hillstone Network AntiVirus
>>

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

* Re: Re: [PATCH] ACPI: LPSS: Fix missing check in register_device_clock
  2022-06-24  2:20   ` huhai
@ 2022-06-29 18:20     ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2022-06-29 18:20 UTC (permalink / raw)
  To: huhai
  Cc: Rafael J. Wysocki, Len Brown, ACPI Devel Maling List,
	Linux Kernel Mailing List, huhai

On Fri, Jun 24, 2022 at 4:35 AM huhai <15815827059@163.com> wrote:
>
>
> At 2022-06-23 21:25:55, "Rafael J. Wysocki" <rafael@kernel.org> wrote:
> >On Thu, Jun 23, 2022 at 3:21 PM huhai <15815827059@163.com> wrote:
> >>
> >> From: huhai <huhai@kylinos.cn>
> >>
> >> register_device_clock() misses a check for platform_device_register_simple().
> >> Add a check to fix it.
> >>
> >> Signed-off-by: huhai <huhai@kylinos.cn>
> >> ---
> >>  drivers/acpi/acpi_lpss.c | 3 +++
> >>  1 file changed, 3 insertions(+)
> >>
> >> diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
> >> index fbe0756259c5..c4d4d21391d7 100644
> >> --- a/drivers/acpi/acpi_lpss.c
> >> +++ b/drivers/acpi/acpi_lpss.c
> >> @@ -422,6 +422,9 @@ static int register_device_clock(struct acpi_device *adev,
> >>         if (!lpss_clk_dev)
> >>                 lpt_register_clock_device();
> >>
> >> +       if (IS_ERR(lpss_clk_dev))
> >> +               return PTR_ERR(lpss_clk_dev);
> >> +
> >
> >Why not use IS_ERR_OR_NULL() instead?
>
> platform_device_register_simple() never returns NULL as it declared bellowing,
> so use IS_ERR() to validate the return value should be enough.
>
> /**
>  * platform_device_register_simple - add a platform-level device and its resources
>  * ...
>  * Returns &struct platform_device pointer on success, or ERR_PTR() on error.
>  */

Fair enough.

Applied as 5.20 material, thanks!

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

end of thread, other threads:[~2022-06-29 18:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-23 13:21 [PATCH] ACPI: LPSS: Fix missing check in register_device_clock huhai
2022-06-23 13:25 ` Rafael J. Wysocki
2022-06-24  2:20   ` huhai
2022-06-29 18:20     ` Rafael J. Wysocki

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.