* [PATCH] acpi: check for null return of devm_kzalloc in fch_misc_setup
@ 2023-02-26 5:54 Kang Chen
2023-03-20 17:06 ` Rafael J. Wysocki
0 siblings, 1 reply; 2+ messages in thread
From: Kang Chen @ 2023-02-26 5:54 UTC (permalink / raw)
To: lenb; +Cc: rafael, linux-acpi, linux-kernel, Kang Chen
devm_kzalloc may fail, clk_data->name might be null and will
cause illegal address access later.
Signed-off-by: Kang Chen <void0red@gmail.com>
---
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 3bbe2276c..80f945cbe 100644
--- a/drivers/acpi/acpi_apd.c
+++ b/drivers/acpi/acpi_apd.c
@@ -83,6 +83,8 @@ static int fch_misc_setup(struct apd_private_data *pdata)
if (!acpi_dev_get_property(adev, "clk-name", ACPI_TYPE_STRING, &obj)) {
clk_data->name = devm_kzalloc(&adev->dev, obj->string.length,
GFP_KERNEL);
+ if (!clk_data->name)
+ return -ENOMEM;
strcpy(clk_data->name, obj->string.pointer);
} else {
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] acpi: check for null return of devm_kzalloc in fch_misc_setup
2023-02-26 5:54 [PATCH] acpi: check for null return of devm_kzalloc in fch_misc_setup Kang Chen
@ 2023-03-20 17:06 ` Rafael J. Wysocki
0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2023-03-20 17:06 UTC (permalink / raw)
To: Kang Chen; +Cc: lenb, rafael, linux-acpi, linux-kernel
On Sun, Feb 26, 2023 at 6:54 AM Kang Chen <void0red@gmail.com> wrote:
>
> devm_kzalloc may fail, clk_data->name might be null and will
> cause illegal address access later.
>
> Signed-off-by: Kang Chen <void0red@gmail.com>
> ---
> 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 3bbe2276c..80f945cbe 100644
> --- a/drivers/acpi/acpi_apd.c
> +++ b/drivers/acpi/acpi_apd.c
> @@ -83,6 +83,8 @@ static int fch_misc_setup(struct apd_private_data *pdata)
> if (!acpi_dev_get_property(adev, "clk-name", ACPI_TYPE_STRING, &obj)) {
> clk_data->name = devm_kzalloc(&adev->dev, obj->string.length,
> GFP_KERNEL);
> + if (!clk_data->name)
> + return -ENOMEM;
>
> strcpy(clk_data->name, obj->string.pointer);
> } else {
> --
Applied as 6.4 material with some edits in the subject and changelog, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-03-20 17:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-26 5:54 [PATCH] acpi: check for null return of devm_kzalloc in fch_misc_setup Kang Chen
2023-03-20 17:06 ` 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