From: Dongliang Mu Date: Thu, 9 Mar 2023 04:01:07 +0000 (+0800) Subject: platform/x86/intel: vsec: Fix a memory leak in intel_vsec_add_aux X-Git-Tag: v6.1.37~2115 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c4043891a10f021b0c6b783e50cc9710ef9d58cf;p=platform%2Fkernel%2Flinux-starfive.git platform/x86/intel: vsec: Fix a memory leak in intel_vsec_add_aux [ 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 Signed-off-by: Dongliang Mu Link: https://lore.kernel.org/r/20230309040107.534716-4-dzm91@hust.edu.cn Reviewed-by: Hans de Goede Signed-off-by: Hans de Goede Signed-off-by: Sasha Levin --- diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c index bb81b8b1f7e9..483bb6565166 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; }