Skip to content

Commit

Permalink
ACPI: processor: Check for null return of devm_kzalloc() in fch_misc_…
Browse files Browse the repository at this point in the history
…setup()

[ Upstream commit 4dea417 ]

devm_kzalloc() may fail, clk_data->name might be NULL and will
cause a NULL pointer dereference later.

Signed-off-by: Kang Chen <void0red@gmail.com>
[ rjw: Subject and changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
void0red authored and gregkh committed May 24, 2023
1 parent cc42732 commit 79ca94b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/acpi/acpi_apd.c
Expand Up @@ -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 {
Expand Down

0 comments on commit 79ca94b

Please sign in to comment.