drm/i915/display: Add check for alloc_ordered_workqueue() and alloc_workqueue()
authorHaoxiang Li <haoxiang_li2024@163.com>
Fri, 16 May 2025 12:16:54 +0000 (15:16 +0300)
committerJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
Thu, 22 May 2025 06:25:57 +0000 (09:25 +0300)
Add check for the return value of alloc_ordered_workqueue()
and alloc_workqueue(). Furthermore, if some allocations fail,
cleanup works are added to avoid potential memory leak problem.

Fixes: 40053823baad ("drm/i915/display: move modeset probe/remove functions to intel_display_driver.c")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://lore.kernel.org/r/20d3d096c6a4907636f8a1389b3b4dd753ca356e.1747397638.git.jani.nikula@intel.com
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
(cherry picked from commit dcab7a228f4ea9cda3f5b0a1f0679e046d23d7f7)
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
drivers/gpu/drm/i915/display/intel_display_driver.c

index 5c74ab5fd1aa50dad856e1bdf2be3a705598194f..411fe7b918a739c0195b764568c0383d70d75741 100644 (file)
@@ -244,31 +244,45 @@ int intel_display_driver_probe_noirq(struct intel_display *display)
        intel_dmc_init(display);
 
        display->wq.modeset = alloc_ordered_workqueue("i915_modeset", 0);
+       if (!display->wq.modeset) {
+               ret = -ENOMEM;
+               goto cleanup_vga_client_pw_domain_dmc;
+       }
+
        display->wq.flip = alloc_workqueue("i915_flip", WQ_HIGHPRI |
                                                WQ_UNBOUND, WQ_UNBOUND_MAX_ACTIVE);
+       if (!display->wq.flip) {
+               ret = -ENOMEM;
+               goto cleanup_wq_modeset;
+       }
+
        display->wq.cleanup = alloc_workqueue("i915_cleanup", WQ_HIGHPRI, 0);
+       if (!display->wq.cleanup) {
+               ret = -ENOMEM;
+               goto cleanup_wq_flip;
+       }
 
        intel_mode_config_init(display);
 
        ret = intel_cdclk_init(display);
        if (ret)
-               goto cleanup_vga_client_pw_domain_dmc;
+               goto cleanup_wq_cleanup;
 
        ret = intel_color_init(display);
        if (ret)
-               goto cleanup_vga_client_pw_domain_dmc;
+               goto cleanup_wq_cleanup;
 
        ret = intel_dbuf_init(display);
        if (ret)
-               goto cleanup_vga_client_pw_domain_dmc;
+               goto cleanup_wq_cleanup;
 
        ret = intel_bw_init(display);
        if (ret)
-               goto cleanup_vga_client_pw_domain_dmc;
+               goto cleanup_wq_cleanup;
 
        ret = intel_pmdemand_init(display);
        if (ret)
-               goto cleanup_vga_client_pw_domain_dmc;
+               goto cleanup_wq_cleanup;
 
        intel_init_quirks(display);
 
@@ -276,6 +290,12 @@ int intel_display_driver_probe_noirq(struct intel_display *display)
 
        return 0;
 
+cleanup_wq_cleanup:
+       destroy_workqueue(display->wq.cleanup);
+cleanup_wq_flip:
+       destroy_workqueue(display->wq.flip);
+cleanup_wq_modeset:
+       destroy_workqueue(display->wq.modeset);
 cleanup_vga_client_pw_domain_dmc:
        intel_dmc_fini(display);
        intel_power_domains_driver_remove(display);