arm64: acpi: Fix possible memory leak of ffh_ctxt
PATCH 1/1 arm64: acpi: Fix possible memory leak of ffh_ctxt
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 Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
Reported-by kernel test robot <[email protected]>
Reported-by Dan Carpenter <[email protected]>
Suggested-by Dan Carpenter <[email protected]>
Signed-off-by Sudeep Holla <[email protected]>
--- arch/arm64/kernel/acpi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm64/kernel/acpi.c +4 -4
@@ -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;
Signature · 7 lines
2.39.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 8 lines · Sudeep Holla
Allocated '
ffh_ctxt' memory leak is possible if the SMCCC version and conduit checks fail and-EOPNOTSUPPis returned without freeing the allocated memory.Fix the same by moving the allocation after the SMCCC version and conduit checks.
[...]
Applied to arm64 (for-next/core), thanks!
[1/1] arm64: acpi: Fix possible memory leak of ffh_ctxt
https://git.kernel.org/arm64/c/1b561d3949f8
Signature · 7 lines
Catalin _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel