Skip to content

Commit f4c7baa

Browse files
Haoxiang Lijlahtine-intel
authored andcommitted
drm/i915/display: Add check for alloc_ordered_workqueue() and alloc_workqueue()
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: 4005382 ("drm/i915/display: move modeset probe/remove functions to intel_display_driver.c") Cc: [email protected] Signed-off-by: Haoxiang Li <[email protected]> Reviewed-by: Matthew Auld <[email protected]> Link: https://lore.kernel.org/r/20d3d096c6a4907636f8a1389b3b4dd753ca356e.1747397638.git.jani.nikula@intel.com Signed-off-by: Jani Nikula <[email protected]> (cherry picked from commit dcab7a2) Signed-off-by: Joonas Lahtinen <[email protected]>
1 parent 9cb1547 commit f4c7baa

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

drivers/gpu/drm/i915/display/intel_display_driver.c

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,38 +244,58 @@ int intel_display_driver_probe_noirq(struct intel_display *display)
244244
intel_dmc_init(display);
245245

246246
display->wq.modeset = alloc_ordered_workqueue("i915_modeset", 0);
247+
if (!display->wq.modeset) {
248+
ret = -ENOMEM;
249+
goto cleanup_vga_client_pw_domain_dmc;
250+
}
251+
247252
display->wq.flip = alloc_workqueue("i915_flip", WQ_HIGHPRI |
248253
WQ_UNBOUND, WQ_UNBOUND_MAX_ACTIVE);
254+
if (!display->wq.flip) {
255+
ret = -ENOMEM;
256+
goto cleanup_wq_modeset;
257+
}
258+
249259
display->wq.cleanup = alloc_workqueue("i915_cleanup", WQ_HIGHPRI, 0);
260+
if (!display->wq.cleanup) {
261+
ret = -ENOMEM;
262+
goto cleanup_wq_flip;
263+
}
250264

251265
intel_mode_config_init(display);
252266

253267
ret = intel_cdclk_init(display);
254268
if (ret)
255-
goto cleanup_vga_client_pw_domain_dmc;
269+
goto cleanup_wq_cleanup;
256270

257271
ret = intel_color_init(display);
258272
if (ret)
259-
goto cleanup_vga_client_pw_domain_dmc;
273+
goto cleanup_wq_cleanup;
260274

261275
ret = intel_dbuf_init(display);
262276
if (ret)
263-
goto cleanup_vga_client_pw_domain_dmc;
277+
goto cleanup_wq_cleanup;
264278

265279
ret = intel_bw_init(display);
266280
if (ret)
267-
goto cleanup_vga_client_pw_domain_dmc;
281+
goto cleanup_wq_cleanup;
268282

269283
ret = intel_pmdemand_init(display);
270284
if (ret)
271-
goto cleanup_vga_client_pw_domain_dmc;
285+
goto cleanup_wq_cleanup;
272286

273287
intel_init_quirks(display);
274288

275289
intel_fbc_init(display);
276290

277291
return 0;
278292

293+
cleanup_wq_cleanup:
294+
destroy_workqueue(display->wq.cleanup);
295+
cleanup_wq_flip:
296+
destroy_workqueue(display->wq.flip);
297+
cleanup_wq_modeset:
298+
destroy_workqueue(display->wq.modeset);
279299
cleanup_vga_client_pw_domain_dmc:
280300
intel_dmc_fini(display);
281301
intel_power_domains_driver_remove(display);

0 commit comments

Comments
 (0)