[next] drm/amd/display: Fix possible NULL dereference in dc_dmub_srv_cmd_run_list()
Message ID | 20230426192413.143971-1-harshit.m.mogalapalli@oracle.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp464617vqo; Wed, 26 Apr 2023 12:33:53 -0700 (PDT) X-Google-Smtp-Source: AKy350a4GqmGoLUYZwzXyLQywQRiVtYT/PpSmOVe2yknkck2Klr841FMg+iJwpTGaShNtUeVoQnl X-Received: by 2002:a17:902:ea07:b0:1a9:5cee:fd47 with SMTP id s7-20020a170902ea0700b001a95ceefd47mr20009423plg.61.1682537632830; Wed, 26 Apr 2023 12:33:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682537632; cv=none; d=google.com; s=arc-20160816; b=PzY+1eI9MTZYjRWWnLqj0xWVZrVH/VbbkN8D+X7pXXcI9vUK6p2wBbDR2ojvh5QMVG NgI9HgkUjRik2xDaBaD7VBRZiPf6VEOW+NKmkST5f0ZyFypZ03XGemlpRNacWQHNTLmm k/jtx6XoVveBcBS413uGyHMXbIUvL7TIdEN8BQhyYb5BgwglWF9e0dJuL+ne+ydnJ6/5 bAgTz7UvY7FYAQer01Mys98l5UMQwaN6UaW1S0kOxmgRkGVPUgKEh9n7gUZO3em6YY1v NrtYo5QtLfsVxJ/FL/APV+FwRt7W0Th53XfOOBdPneiPQX5/IwGd0gzziBcCRJLX1D49 sr5A== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r11-20020a1709028bcb00b001a961300697si10440732plo.589.2023.04.26.12.33.37; Wed, 26 Apr 2023 12:33:52 -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 S239424AbjDZTYr (ORCPT <rfc822;zxc52fgh@gmail.com> + 99 others); Wed, 26 Apr 2023 15:24:47 -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 <rfc822;linux-kernel@vger.kernel.org>); 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 <harshit.m.mogalapalli@oracle.com> Cc: error27@gmail.com, kernel-janitors@vger.kernel.org, Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>, Harry Wentland <harry.wentland@amd.com>, Leo Li <sunpeng.li@amd.com>, Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>, Alex Deucher <alexander.deucher@amd.com>, =?utf-8?q?Christian_K=C3=B6nig?= <christian.koenig@amd.com>, "Pan, Xinhui" <Xinhui.Pan@amd.com>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>, Alvin Lee <Alvin.Lee2@amd.com>, Jun Lei <Jun.Lei@amd.com>, Qingqing Zhuo <qingqing.zhuo@amd.com>, Josip Pavic <Josip.Pavic@amd.com>, Max Tseng <Max.Tseng@amd.com>, Eric Yang <Eric.Yang2@amd.com>, Nicholas Kazlauskas <Nicholas.Kazlauskas@amd.com>, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764268580834952886?= X-GMAIL-MSGID: =?utf-8?q?1764268580834952886?= |
Series |
[next] drm/amd/display: Fix possible NULL dereference in dc_dmub_srv_cmd_run_list()
|
|
Commit Message
Harshit Mogalapalli
April 26, 2023, 7:24 p.m. UTC
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 <harshit.m.mogalapalli@oracle.com>
---
Only compile tested.
---
drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On 4/26/23 15:24, Harshit Mogalapalli wrote: > 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 <harshit.m.mogalapalli@oracle.com> Applied, thanks! > --- > 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++) {
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++) {