platform/x86/intel: vsec: Fix a memory leak in intel_vsec_add_aux
authorDongliang Mu <dzm91@hust.edu.cn>
Thu, 9 Mar 2023 04:01:07 +0000 (12:01 +0800)
committerHans de Goede <hdegoede@redhat.com>
Mon, 20 Mar 2023 12:11:55 +0000 (13:11 +0100)
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@linux.intel.com>
Signed-off-by: Dongliang Mu <dzm91@hust.edu.cn>
Link: https://lore.kernel.org/r/20230309040107.534716-4-dzm91@hust.edu.cn
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/x86/intel/vsec.c

index 13decf36c6ded9740ce67b9adbd3c637e1829517..2311c16cb975de8b44f99d97b14e5dcfd3af5f48 100644 (file)
@@ -154,6 +154,7 @@ int intel_vsec_add_aux(struct pci_dev *pdev, struct device *parent,
        ret = ida_alloc(intel_vsec_dev->ida, GFP_KERNEL);
        mutex_unlock(&vsec_ida_lock);
        if (ret < 0) {
+               kfree(intel_vsec_dev->resource);
                kfree(intel_vsec_dev);
                return ret;
        }