Patch "arm64: acpi: Fix possible memory leak of ffh_ctxt" has been added to the 6.2-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    arm64: acpi: Fix possible memory leak of ffh_ctxt

to the 6.2-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     arm64-acpi-fix-possible-memory-leak-of-ffh_ctxt.patch
and it can be found in the queue-6.2 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.


>From 1b561d3949f8478c5403c9752b5533211a757226 Mon Sep 17 00:00:00 2001
From: Sudeep Holla <sudeep.holla@xxxxxxx>
Date: Thu, 23 Feb 2023 13:57:42 +0000
Subject: arm64: acpi: Fix possible memory leak of ffh_ctxt

From: Sudeep Holla <sudeep.holla@xxxxxxx>

commit 1b561d3949f8478c5403c9752b5533211a757226 upstream.

Allocated 'ffh_ctxt' memory leak is possible if the SMCCC version
and conduit checks fail and -EOPNOTSUPP is returned without freeing the
allocated memory.

Fix the same by moving the allocation after the SMCCC version and
conduit checks.

Fixes: 1d280ce099db ("arm64: Add architecture specific ACPI FFH Opregion callbacks")
Cc: <stable@xxxxxxxxxxxxxxx> # 6.2.x
Cc: Will Deacon <will@xxxxxxxxxx>
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <error27@xxxxxxxxx>
Suggested-by: Dan Carpenter <error27@xxxxxxxxx>
Link: https://lore.kernel.org/r/202302191417.dAl9NuE8-lkp@xxxxxxxxx/
Signed-off-by: Sudeep Holla <sudeep.holla@xxxxxxx>
Link: https://lore.kernel.org/r/20230223135742.2952091-1-sudeep.holla@xxxxxxx
Signed-off-by: Catalin Marinas <catalin.marinas@xxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 arch/arm64/kernel/acpi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
index 378453faa87e..dba8fcec7f33 100644
--- a/arch/arm64/kernel/acpi.c
+++ b/arch/arm64/kernel/acpi.c
@@ -435,10 +435,6 @@ int acpi_ffh_address_space_arch_setup(void *handler_ctxt, void **region_ctxt)
 	enum arm_smccc_conduit conduit;
 	struct acpi_ffh_data *ffh_ctxt;
 
-	ffh_ctxt = kzalloc(sizeof(*ffh_ctxt), GFP_KERNEL);
-	if (!ffh_ctxt)
-		return -ENOMEM;
-
 	if (arm_smccc_get_version() < ARM_SMCCC_VERSION_1_2)
 		return -EOPNOTSUPP;
 
@@ -448,6 +444,10 @@ int acpi_ffh_address_space_arch_setup(void *handler_ctxt, void **region_ctxt)
 		return -EOPNOTSUPP;
 	}
 
+	ffh_ctxt = kzalloc(sizeof(*ffh_ctxt), GFP_KERNEL);
+	if (!ffh_ctxt)
+		return -ENOMEM;
+
 	if (conduit == SMCCC_CONDUIT_SMC) {
 		ffh_ctxt->invoke_ffh_fn = __arm_smccc_smc;
 		ffh_ctxt->invoke_ffh64_fn = arm_smccc_1_2_smc;
-- 
2.39.2



Patches currently in stable-queue which might be from sudeep.holla@xxxxxxx are

queue-6.2/driver-core-fw_devlink-consolidate-device-link-flag-.patch
queue-6.2/driver-core-fw_devlink-allow-marking-a-fwnode-link-a.patch
queue-6.2/driver-core-fw_devlink-improve-check-for-fwnode-with.patch
queue-6.2/arm64-acpi-fix-possible-memory-leak-of-ffh_ctxt.patch
queue-6.2/driver-core-fw_devlink-add-dl_flag_cycle-support-to-.patch
queue-6.2/driver-core-fw_devlink-make-cycle-detection-more-rob.patch
queue-6.2/driver-core-fw_devlink-don-t-purge-child-fwnode-s-co.patch



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux