Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2380954ybt; Tue, 16 Jun 2020 04:46:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTn0e69UzuNMgfDgcXFLXstUFYGaNjqWwYdXYntZU0qGrSmK6pyTOoMKBg7O/U2N9zhjA1 X-Received: by 2002:aa7:d5c7:: with SMTP id d7mr2187718eds.11.1592308008561; Tue, 16 Jun 2020 04:46:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592308008; cv=none; d=google.com; s=arc-20160816; b=qNHddcTQt598wW7mY09i5BA59FDtP9ROqrfNhswclAxvtrZg556F1oeIcuFuyuv8W7 rV12UNO1/Ek3QU4aX2DjWAMiyYSb7wjndyltiymoLr73Y3T35asOsmEnsCf3WxmtVmND RbkEyqEa/nDbuuzVALwu8q7/p1gSPZ+oIgC0TwGgEXVX/MYLtjCA8FTPj/sxCv6vOFOX sIL4pkI43tBcIx2fVZw2J7kmeCW4mTwe4pt41GbAKQHsch+q4SsXyBjpUUJn0L+YMMO2 VgSHhcQa34s/pYXDEkKZ0ND4q/jTOfB5DMxtv27oO7bqFU2CdG5n7sU93/YuENHos0vW H31w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Vp7JzPCsKl0mLHc7x4NQ+YEAW/NGv+iPOWVNCRuABN8=; b=P55t1iKN/gqQ0+rYNiHEQuzFsZ/gn+1WyPt98vIdeMIQK0C3qRhSpdEP7YoQlN7Hze qSeDJ+yUqsa8sreFez+XI7Dzz7xMJr5Ujr1MjxEfoDYdUxSaNznaA3/Jtfl/xjRlN18a e//Hl6csJohi+T+BHABkO6tbpKXukN64trt6wlQxiHzIvJCk00GUlY4DXJcD8+yWORwj 5usvMiDsSH0opxhv+qGbltRM3NuAew/kNCn7mPUYymf6mVpdPjdDeZeQgviqUIBB4a5C a1IUObmfKNY31QV2tG/RQZ+cKYCWsQIxd1yMAIa4CraS9P4GUV/dH5bNZaeEeb+kh3Bd GlFA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b10si10221397edw.184.2020.06.16.04.46.26; Tue, 16 Jun 2020 04:46:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728428AbgFPLmb (ORCPT + 99 others); Tue, 16 Jun 2020 07:42:31 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:51173 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725775AbgFPLmb (ORCPT ); Tue, 16 Jun 2020 07:42:31 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jl9yv-0006sx-D3; Tue, 16 Jun 2020 11:42:21 +0000 From: Colin King To: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , Daniel Vetter , Animesh Manna , Maarten Lankhorst , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/i915/display: fix missing null check on allocated dsb object Date: Tue, 16 Jun 2020 12:42:21 +0100 Message-Id: <20200616114221.73971-1-colin.king@canonical.com> X-Mailer: git-send-email 2.27.0.rc0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King 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 --- drivers/gpu/drm/i915/display/intel_dsb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/i915/display/intel_dsb.c b/drivers/gpu/drm/i915/display/intel_dsb.c index 24e6d63e2d47..566fa72427b3 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); -- 2.27.0.rc0