[PATCH AUTOSEL 6.2 02/17] platform/x86/intel: vsec: Fix a memory leak in intel_vsec_add_aux
From: Sasha Levin
Date: Thu Apr 06 2023 - 07:31:43 EST
From: Dongliang Mu <dzm91@xxxxxxxxxxx>
[ Upstream commit da0ba0ccce54059d6c6b788a75099bfce95126da ]
The first error handling code in intel_vsec_add_aux misses the
deallocation of intel_vsec_dev->resource.
Fix this by adding kfree(intel_vsec_dev->resource) in the error handling
code.
Reviewed-by: David E. Box <david.e.box@xxxxxxxxxxxxxxx>
Signed-off-by: Dongliang Mu <dzm91@xxxxxxxxxxx>
Link: https://lore.kernel.org/r/20230309040107.534716-4-dzm91@xxxxxxxxxxx
Reviewed-by: Hans de Goede <hdegoede@xxxxxxxxxx>
Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
drivers/platform/x86/intel/vsec.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c
index 89c5374e33b32..bcbd522d062bf 100644
--- a/drivers/platform/x86/intel/vsec.c
+++ b/drivers/platform/x86/intel/vsec.c
@@ -141,6 +141,7 @@ static int intel_vsec_add_aux(struct pci_dev *pdev, struct intel_vsec_device *in
ret = ida_alloc(intel_vsec_dev->ida, GFP_KERNEL);
if (ret < 0) {
+ kfree(intel_vsec_dev->resource);
kfree(intel_vsec_dev);
return ret;
}
--
2.39.2