Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1270887rwr; Wed, 26 Apr 2023 12:25:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7rGLjxYzQ1iOuFidiDmTaaT+0tCCGvwPr2etZ129XzqZWOHHnqF7V5rGOOEcw969+aGeBp X-Received: by 2002:a17:903:41c3:b0:1a9:80a0:47fc with SMTP id u3-20020a17090341c300b001a980a047fcmr11281040ple.17.1682537125357; Wed, 26 Apr 2023 12:25:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682537125; cv=none; d=google.com; s=arc-20160816; b=CL15QQRBC/bdtOsvMDBYnxIgwh3AzGK9TjuO1HkIdo73rEGNXYedv9eK4T3Q021fpl h8IRMjDy9XL46HX9+VVenAHV4IKItdPc+j3HaiUMvRXW/tKnIA2BDPfv6cKmAj8CUv0T Jq7Wfpfn823h/nEaIzNO3X4Eca6BS0njuM2o/qJRfmYKdYjrAFQHJfU/2h9FO2uZyPdh JfB47Qxjqf/e2Ne8P5udv8ENxzWeUIctfD3+s469a0jU7OS9y4grkpGWVWntfZuZAfBU Jj4/z5XNmCRluNGqGnjygoh/cVHSsXcMR4CN0+5I2/Rvf4rQxfzYEpblN1WYzvz5oDwe /7kQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=q2mNaPnyPQXXOVMMyGNZC0+Exw9ul90KlaFLguRPbSE=; b=PKqk1nts27HfoUQfiADMhnqG9dmCRVXMilG2WjrsA47GVx50iGm4GhFRAU6R7k7wDw XrbAWEaPdkjPGbHofcbrT3hEA6Q/Z2+JjxLV29g/SwhF/C8yhsxd5Nx2stFMTJrgTl9l FlEXVlyor6UGwCuAZGhve8+QA8ciZyoCC96axJQmuI/E0zzmOqtnx2opn222u0sTQvWi oFPXERxYvl4NL99UFiZIqQYV5KvxL3YuLXJDwZdxLaniShal+dIwJ32m16nLiQ2aOEu7 yRVbdBzn5Qe3kDmfuepVXckjn/rrQxK0wSW6U+c7Xhf3PAcLY2yQIv/EWF3JoXCDz4pN +ZHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@oracle.com header.s=corp-2023-03-30 header.b=JTI3gr9J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z15-20020a170902d54f00b001a64f99cb73si17452892plf.530.2023.04.26.12.25.08; Wed, 26 Apr 2023 12:25:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@oracle.com header.s=corp-2023-03-30 header.b=JTI3gr9J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238988AbjDZTYq (ORCPT + 99 others); Wed, 26 Apr 2023 15:24:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234643AbjDZTYo (ORCPT ); Wed, 26 Apr 2023 15:24:44 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 667946E81; Wed, 26 Apr 2023 12:24:22 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33QGwraf017013; Wed, 26 Apr 2023 19:24:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2023-03-30; bh=q2mNaPnyPQXXOVMMyGNZC0+Exw9ul90KlaFLguRPbSE=; b=JTI3gr9Jfaw0OpyNVhlii954Oj6UeFNzJrFkR1cAXaIfNkWeWtSouV/SpKwHTdEQJMWw /X98SRnlDp7sHfDH6KUMIymcVxVpCLY0ijU347uq+8i/JWmX/6LpOkna0PfRTsMcC1i5 9O9EDUtwf9ndhJccOCb7XH2fBR0/zFDUJSc8pL60V/e8Ip0BEPEVgvE+0ylpnJ3OoDP0 2LCBvL3mVIYp4T1V25oMFXhVaOlXOLIUEkRs4940xpQ/4Ff8EQ4ly8QqKLQFm8GDwsN5 ISUzrjPsG/S3o67CD8kFldecx7sdISs5nUEya1HA22vUxB6YT1K0i9ugOM1F8iDvnaVB /A== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3q476u28gj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Apr 2023 19:24:18 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 33QILsg2032779; Wed, 26 Apr 2023 19:24:17 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3q4618kp2a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Apr 2023 19:24:17 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 33QJOGXc020578; Wed, 26 Apr 2023 19:24:16 GMT Received: from ca-dev112.us.oracle.com (ca-dev112.us.oracle.com [10.129.136.47]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3q4618kp1p-1; Wed, 26 Apr 2023 19:24:16 +0000 From: Harshit Mogalapalli Cc: error27@gmail.com, kernel-janitors@vger.kernel.org, Harshit Mogalapalli , Harry Wentland , Leo Li , Rodrigo Siqueira , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , Alvin Lee , Jun Lei , Qingqing Zhuo , Josip Pavic , Max Tseng , Eric Yang , Nicholas Kazlauskas , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH next] drm/amd/display: Fix possible NULL dereference in dc_dmub_srv_cmd_run_list() Date: Wed, 26 Apr 2023 12:24:12 -0700 Message-Id: <20230426192413.143971-1-harshit.m.mogalapalli@oracle.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-26_10,2023-04-26_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304260173 X-Proofpoint-GUID: Mog46ec3betvlKJ3ZxvRDkD0ckgkGrie X-Proofpoint-ORIG-GUID: Mog46ec3betvlKJ3ZxvRDkD0ckgkGrie X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We have a NULL check for 'dc_dmub_srv' in dc_dmub_srv_cmd_run_list() but we are dereferencing it before checking. Fix this moving the dereference next to NULL check. This issue is found with Smatch(static analysis tool). Fixes: e97cc04fe0fb ("drm/amd/display: refactor dmub commands into single function") Signed-off-by: Harshit Mogalapalli --- Only compile tested. --- drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c b/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c index d15ec32243e2..62d3473c32bc 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c +++ b/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c @@ -125,7 +125,7 @@ bool dc_dmub_srv_cmd_run(struct dc_dmub_srv *dc_dmub_srv, union dmub_rb_cmd *cmd bool dc_dmub_srv_cmd_run_list(struct dc_dmub_srv *dc_dmub_srv, unsigned int count, union dmub_rb_cmd *cmd_list, enum dm_dmub_wait_type wait_type) { - struct dc_context *dc_ctx = dc_dmub_srv->ctx; + struct dc_context *dc_ctx; struct dmub_srv *dmub; enum dmub_status status; int i; @@ -133,6 +133,7 @@ bool dc_dmub_srv_cmd_run_list(struct dc_dmub_srv *dc_dmub_srv, unsigned int coun if (!dc_dmub_srv || !dc_dmub_srv->dmub) return false; + dc_ctx = dc_dmub_srv->ctx; dmub = dc_dmub_srv->dmub; for (i = 0 ; i < count; i++) { -- 2.38.1