drm/amd/pm/smu7: fix a memleak in smu7_hwmgr_backend_init
authorjsg <jsg@openbsd.org>
Mon, 29 Jan 2024 01:51:19 +0000 (01:51 +0000)
committerjsg <jsg@openbsd.org>
Mon, 29 Jan 2024 01:51:19 +0000 (01:51 +0000)
From Zhipeng Lu
ae7cbf935b9a1b41f65fe6443e7cd0c401500b20 in linux-6.6.y/6.6.14
2f3be3ca779b11c332441b10e00443a2510f4d7b in mainline linux

sys/dev/pci/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c

index 120354c..6fabd1e 100644 (file)
@@ -2974,6 +2974,8 @@ static int smu7_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
                result = smu7_get_evv_voltages(hwmgr);
                if (result) {
                        pr_info("Get EVV Voltage Failed.  Abort Driver loading!\n");
+                       kfree(hwmgr->backend);
+                       hwmgr->backend = NULL;
                        return -EINVAL;
                }
        } else {
@@ -3019,8 +3021,10 @@ static int smu7_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
        }
 
        result = smu7_update_edc_leakage_table(hwmgr);
-       if (result)
+       if (result) {
+               smu7_hwmgr_backend_fini(hwmgr);
                return result;
+       }
 
        return 0;
 }