From: Kang Chen <void0red@gmail.com>
To: lenb@kernel.org
Cc: rafael@kernel.org, linux-acpi@vger.kernel.org,
linux-kernel@vger.kernel.org, Kang Chen <void0red@gmail.com>
Subject: [PATCH] acpi: check for null return of devm_kzalloc in fch_misc_setup
Date: Sun, 26 Feb 2023 13:54:27 +0800 [thread overview]
Message-ID: <20230226055427.2512453-1-void0red@gmail.com> (raw)
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
next reply other threads:[~2023-02-26 5:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-26 5:54 Kang Chen [this message]
2023-03-20 17:06 ` [PATCH] acpi: check for null return of devm_kzalloc in fch_misc_setup Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230226055427.2512453-1-void0red@gmail.com \
--to=void0red@gmail.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox