From: Colin Ian King Date: Tue, 16 Jun 2020 11:42:21 +0000 (+0100) Subject: drm/i915/display: fix missing null check on allocated dsb object X-Git-Tag: v5.9-rc1~134^2~18^2~21 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=607856a835539c465015882328f1e37e95de8ee7;p=thirdparty%2Fkernel%2Flinux.git drm/i915/display: fix missing null check on allocated dsb object Currently there is no null check for a failed memory allocation on the dsb object and without this a null pointer dereference error can occur. Fix this by adding a null check. Note: added a drm_err message in keeping with the error message style in the function. Addresses-Coverity: ("Dereference null return") Fixes: afeda4f3b1c8 ("drm/i915/dsb: Pre allocate and late cleanup of cmd buffer") Signed-off-by: Colin Ian King Signed-off-by: Jani Nikula Link: https://patchwork.freedesktop.org/patch/msgid/20200616114221.73971-1-colin.king@canonical.com --- diff --git a/drivers/gpu/drm/i915/display/intel_dsb.c b/drivers/gpu/drm/i915/display/intel_dsb.c index 24e6d63e2d476..566fa72427b33 100644 --- a/drivers/gpu/drm/i915/display/intel_dsb.c +++ b/drivers/gpu/drm/i915/display/intel_dsb.c @@ -271,6 +271,10 @@ void intel_dsb_prepare(struct intel_crtc_state *crtc_state) return; dsb = kmalloc(sizeof(*dsb), GFP_KERNEL); + if (!dsb) { + drm_err(&i915->drm, "DSB object creation failed\n"); + return; + } wakeref = intel_runtime_pm_get(&i915->runtime_pm);