linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ACPI: APD: Check for null pointer after calling devm_ioremap
@ 2022-01-07  3:35 Jiasheng Jiang
  2022-01-11 15:36 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Jiasheng Jiang @ 2022-01-07  3:35 UTC (permalink / raw)
  To: rjw, lenb; +Cc: linux-acpi, linux-kernel, Jiasheng Jiang

As the possible failure of the devres_alloc(), the devm_ioremap() may
return NULL pointer.
And then, the 'clk_data->base' will be assigned to clkdev->data->base in
platform_device_register_data().
And the PTR_ERR_OR_ZERO() can not detect the 'base'.
Therefore, it should be better to add the check in order to guarantee
the success of the setup.

Fixes: 3f4ba94e3615 ("ACPI: APD: Add AMD misc clock handler support")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/acpi/acpi_apd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c
index 6e02448d15d9..9db6409ecb47 100644
--- a/drivers/acpi/acpi_apd.c
+++ b/drivers/acpi/acpi_apd.c
@@ -95,6 +95,8 @@ static int fch_misc_setup(struct apd_private_data *pdata)
 					      resource_size(rentry->res));
 		break;
 	}
+	if (!clk_data->base)
+		return -ENOMEM;
 
 	acpi_dev_free_resource_list(&resource_list);
 
-- 
2.25.1


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

* Re: [PATCH] ACPI: APD: Check for null pointer after calling devm_ioremap
  2022-01-07  3:35 [PATCH] ACPI: APD: Check for null pointer after calling devm_ioremap Jiasheng Jiang
@ 2022-01-11 15:36 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2022-01-11 15:36 UTC (permalink / raw)
  To: Jiasheng Jiang
  Cc: Rafael J. Wysocki, Len Brown, ACPI Devel Maling List,
	Linux Kernel Mailing List

On Fri, Jan 7, 2022 at 4:35 AM Jiasheng Jiang <jiasheng@iscas.ac.cn> wrote:
>
> As the possible failure of the devres_alloc(), the devm_ioremap() may
> return NULL pointer.
> And then, the 'clk_data->base' will be assigned to clkdev->data->base in
> platform_device_register_data().
> And the PTR_ERR_OR_ZERO() can not detect the 'base'.
> Therefore, it should be better to add the check in order to guarantee
> the success of the setup.
>
> Fixes: 3f4ba94e3615 ("ACPI: APD: Add AMD misc clock handler support")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
>  drivers/acpi/acpi_apd.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c
> index 6e02448d15d9..9db6409ecb47 100644
> --- a/drivers/acpi/acpi_apd.c
> +++ b/drivers/acpi/acpi_apd.c
> @@ -95,6 +95,8 @@ static int fch_misc_setup(struct apd_private_data *pdata)
>                                               resource_size(rentry->res));
>                 break;
>         }
> +       if (!clk_data->base)
> +               return -ENOMEM;
>
>         acpi_dev_free_resource_list(&resource_list);
>
> --

Applied as 5.17-rc material with a rewritten changelog, thanks!

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

end of thread, other threads:[~2022-01-11 15:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-07  3:35 [PATCH] ACPI: APD: Check for null pointer after calling devm_ioremap Jiasheng Jiang
2022-01-11 15:36 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).