Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp868544pxb; Tue, 1 Feb 2022 12:05:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJycwUYDbNECJgSeycI8AGbJoGaTp6RL3qv34Morc6JCFVCWE9K9QJfwelKvG+pbW/kq1VM3 X-Received: by 2002:a17:907:1ddd:: with SMTP id og29mr23638137ejc.395.1643745944216; Tue, 01 Feb 2022 12:05:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643745944; cv=none; d=google.com; s=arc-20160816; b=VY/igMfmeL3qP6azMT3kZvD6hM2kXaFy0zsjJONO3cMapZTu3sodME/1FDD/Q8Srl5 Xj4vFHsBLdW9VXW7ciu9V9FGP36UlHBsvJF7Ap3dCex8tl2uxYb868mqOIvyZfQzv+s8 dmfhJctuV+g7cooDYlrJemXGBNd4u02wSyuMUP8DtM00WIma1ylwb9vZ80us1LbFlpS/ ysk2wfmIZwX9r96jdUonAOvBJVYAcGzgR9UGLngB3WXPbwpKKQ1hIEA2CKLlHVV9snCu AEavGs1V3H7TNm2nn/broj/hxrPdIcw1B75X1XagqVeHeCDPGWETU0HL3U7Aw7yg+vjt D6/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=V4tVIo6ILQp/Jh+biMPNFbvVWP4K5WbGrnIA8slVitc=; b=1KAr6OdpDcOYocjPpyyrenzR9Y99ZBo1lAtC/8o1Dva0y5NfWC/IMfs4oj94mTKxbF rJI0lzUnUZ3nWxr30BQcD+W9gb/QbCoiQ+7VKvNL3LB4GhZLf0xYXIG+5Y6GaeNXRFT+ dTCSwOJ4klDQloMCwRrXyh9CYTok5CRJ5toeDkVnXBCtyCH0A8FkVipvZ3N5pCZJM7I+ yksjSC5hf59q7gwBEeF8yI2wMKXRkw4s4Dt4Yv5yQMIPcbFlNJZflVllRxTky9RTRnZ8 esInaPQSboCMnPkuIgKT2KEUlyS9OK7VXT1MzY4Fdss4YiEbSKlXJ/Bske3nYRTyobEY KBQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AkoOvEbG; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds19si10721698ejc.458.2022.02.01.12.05.17; Tue, 01 Feb 2022 12:05:44 -0800 (PST) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AkoOvEbG; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349327AbiAaLQG (ORCPT + 99 others); Mon, 31 Jan 2022 06:16:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376844AbiAaLJL (ORCPT ); Mon, 31 Jan 2022 06:09:11 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3249C0610EC; Mon, 31 Jan 2022 03:05:40 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C0701B82A71; Mon, 31 Jan 2022 11:05:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0389BC340EF; Mon, 31 Jan 2022 11:05:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643627138; bh=Ic9+VcG7lFp7Q3GuEkC8fKcySwrc/W83HucGFrLwprE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AkoOvEbGc3nRiU/0lxMFQtfFwsm875JSc092QgUM8LowuRxbnufnCyMoRiw9UyMTe /4mOiHncQNzazR8PzAWqfNZkCBLmS/yRETNIYodr1lxuW7+CvvvL2qGQMFsHws9aAf oIkeMg+ad03LXJ5PA1GVmo5KMuRkhKekx7LJ1s/c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= , Dmitry Baryshkov , Sasha Levin Subject: [PATCH 5.10 087/100] drm/msm/dpu: invalid parameter check in dpu_setup_dspp_pcc Date: Mon, 31 Jan 2022 11:56:48 +0100 Message-Id: <20220131105223.386734401@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220131105220.424085452@linuxfoundation.org> References: <20220131105220.424085452@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: José Expósito [ Upstream commit 170b22234d5495f5e0844246e23f004639ee89ba ] The function performs a check on the "ctx" input parameter, however, it is used before the check. Initialize the "base" variable after the sanity check to avoid a possible NULL pointer dereference. Fixes: 4259ff7ae509e ("drm/msm/dpu: add support for pcc color block in dpu driver") Addresses-Coverity-ID: 1493866 ("Null pointer dereference") Signed-off-by: José Expósito Link: https://lore.kernel.org/r/20220109192431.135949-1-jose.exposito89@gmail.com Signed-off-by: Dmitry Baryshkov Signed-off-by: Sasha Levin --- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dspp.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dspp.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dspp.c index a7a24539921f3..a6efc11eba93f 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dspp.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dspp.c @@ -26,9 +26,16 @@ static void dpu_setup_dspp_pcc(struct dpu_hw_dspp *ctx, struct dpu_hw_pcc_cfg *cfg) { - u32 base = ctx->cap->sblk->pcc.base; + u32 base; - if (!ctx || !base) { + if (!ctx) { + DRM_ERROR("invalid ctx %pK\n", ctx); + return; + } + + base = ctx->cap->sblk->pcc.base; + + if (!base) { DRM_ERROR("invalid ctx %pK pcc base 0x%x\n", ctx, base); return; } -- 2.34.1