From: Hanjun Guo <guohanjun@huawei.com>
To: Charles Han <hanchunchao@inspur.com>, <rafael@kernel.org>,
<tony.luck@intel.com>, <bp@alien8.de>, <mchehab@kernel.org>,
<xueshuai@linux.alibaba.com>, <lenb@kernel.org>,
<ira.weiny@intel.com>, <zaidal@os.amperecomputing.com>,
<Jonathan.Cameron@huawei.com>, <colin.i.king@gmail.com>,
<dan.carpenter@linaro.org>, <dan.j.williams@intel.com>,
<sudeep.holla@arm.com>
Cc: <linux-acpi@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ACPI: APEI: EINJ: fix potential NULL dereference in __einj_error_inject
Date: Tue, 19 Aug 2025 00:06:49 +0800 [thread overview]
Message-ID: <547301a8-5a66-7958-15be-0bcf01dd8a62@huawei.com> (raw)
In-Reply-To: <20250815024207.3038-1-hanchunchao@inspur.com>
On 2025/8/15 10:42, Charles Han wrote:
> The __einj_error_inject() function allocates memory via kmalloc()
> without checking for allocation failure, which could lead to a
> NULL pointer dereference.
>
> Return -ENOMEM in case allocation fails.
>
> Fixes: b47610296d17 ("ACPI: APEI: EINJ: Enable EINJv2 error injections")
> Signed-off-by: Charles Han <hanchunchao@inspur.com>
> ---
> drivers/acpi/apei/einj-core.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
> index bf8dc92a373a..93a3ae1325e5 100644
> --- a/drivers/acpi/apei/einj-core.c
> +++ b/drivers/acpi/apei/einj-core.c
> @@ -540,6 +540,9 @@ static int __einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
> struct set_error_type_with_address *v5param;
>
> v5param = kmalloc(v5param_size, GFP_KERNEL);
> + if (!v5param)
> + return -ENOMEM;
> +
> memcpy_fromio(v5param, einj_param, v5param_size);
> v5param->type = type;
> if (type & ACPI5_VENDOR_BIT) {
Reviewed-by: Hanjun Guo <guohanjun@huawei.com>
Thanks
Hanjun
next prev parent reply other threads:[~2025-08-18 16:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-15 2:42 Charles Han
2025-08-15 15:51 ` Luck, Tony
2025-08-18 16:06 ` Hanjun Guo [this message]
2025-08-18 16:11 ` Rafael J. Wysocki
2025-08-19 14:04 ` Yazen Ghannam
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=547301a8-5a66-7958-15be-0bcf01dd8a62@huawei.com \
--to=guohanjun@huawei.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=bp@alien8.de \
--cc=colin.i.king@gmail.com \
--cc=dan.carpenter@linaro.org \
--cc=dan.j.williams@intel.com \
--cc=hanchunchao@inspur.com \
--cc=ira.weiny@intel.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=rafael@kernel.org \
--cc=sudeep.holla@arm.com \
--cc=tony.luck@intel.com \
--cc=xueshuai@linux.alibaba.com \
--cc=zaidal@os.amperecomputing.com \
/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
all inboxes | Powered by JetHome®