Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp17131992rwd; Mon, 26 Jun 2023 21:37:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4v723ekWdL+aRazY1vgbdw9bZ43xCHWP9vVPgewUBb9hWS1VdsEpbDK3fDyAkuKWoRFYtB X-Received: by 2002:a17:907:94ca:b0:992:2875:9450 with SMTP id dn10-20020a17090794ca00b0099228759450mr299390ejc.48.1687840623544; Mon, 26 Jun 2023 21:37:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687840623; cv=none; d=google.com; s=arc-20160816; b=UwbM9/bSSDyMn6ffe9Ez9rSZf4PAnhSl8tHy5vpHSf1hKCkcDaOGdtWRFV/Lr//Ksp 9Rff1nqfndqQ5N9uYLOWo7EbhGxMnEXinyVRFx/iuc9JinbNqWlcGz7zcyXPuT7tGK+T iuOpaVNzWBYhmJURSFxFHgMOTWhCwsX6qCemGNZac2frxN65m5eJuH3+aNlV9wic5qdn j8O1jkqZyi7FrYo4UgDlDe1j8HdfFrJuCQDkvQoxdEVWQ+MkRWnsdlqkKbLfMefKLrf+ O47pJxyzXKf91YnqKzChCN32dXasrdJzcMkriNJ2umcckrTCFwPzF1cmuecZy8Sz/1Va w7Yg== 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=qE1HJ292s3PXvLRoSr2Nw3hL8I7+kggKD9BrBYerbDA=; fh=8UH73LWjOV8ygVZLFQJqr9qyaRrIbFs3yXh90xR4d3o=; b=A+J5yJq7GHwVP+Ht8KCaqzG9/nJFSSDRHkyYIzxBcRQGX32nihIMkxTnOIfCWwgIgC FO+y62guhjEzCMA74ucmGSvJv5cIYiVDsv9l+2OmM0D2ZNDhPZHPmPa3tjtjolvuve1y NypobtooKMYW1gELMZFF6HZEVrxB/RxfkVlcmveDFjl08ROkUino7Mv9s+dGrGlXi3J6 HvLt8K3kbyKacSOOXAvX4kpY0y2qK4sI9dEHaW1CVwcnuLplKNMw+ntBtiUQT1rmso3/ e2gmQikt9BltVdqVr1cLyhCb7sA3gPCm6AeG36sKlSRafFv8SLwOGMTLx4ZfNxnfmJBd fX0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@oracle.com header.s=corp-2023-03-30 header.b=a5t50CXV; 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 bm6-20020a170906c04600b00982a36463c9si3621155ejb.518.2023.06.26.21.36.38; Mon, 26 Jun 2023 21:37:03 -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=a5t50CXV; 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 S230033AbjF0ENm (ORCPT + 99 others); Tue, 27 Jun 2023 00:13:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230030AbjF0ENk (ORCPT ); Tue, 27 Jun 2023 00:13:40 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75BEE10FC; Mon, 26 Jun 2023 21:13:39 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35QMjDNN029311; Tue, 27 Jun 2023 04:13:23 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=qE1HJ292s3PXvLRoSr2Nw3hL8I7+kggKD9BrBYerbDA=; b=a5t50CXV4q8mIIpAJq12aaDS/qBcZvmjsY+27MVXUsvUPmreAXKZ5Gu40e0RceaWryoP 6jUsKdSxVQ6o9vqZF8AAyCptj/QH330OLUNFvGLsb0iEQg0anIe+AkQqNLQgHiJ00vVl w6UDOrr7AFQzr6Ave5R9AnWibIJfNwnFYKmSXFMGXXnCf5wdYEIQZB0umN4Ae46UqhDH Mumx9Ekv08CvodsXBk+deCrb1YA3kgAZ2LhVXTgdRFHIguMJ3Ri1MJPKMcgQNe62yO34 Nf0EPxwh44p4LHMlgY89Wq5qlLiYEK3Huv7JRo8F+K2i2YOI3R3E7O5c7rs392GbuUx5 4g== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rds1u3yvr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 27 Jun 2023 04:13:22 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35R1DS8U026348; Tue, 27 Jun 2023 04:13:21 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpxaehdq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 27 Jun 2023 04:13:21 +0000 Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 35R4DLTQ009154; Tue, 27 Jun 2023 04:13:21 GMT Received: from ca-dev112.us.oracle.com (ca-dev112.us.oracle.com [10.129.136.47]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3rdpxaeh80-1; Tue, 27 Jun 2023 04:13:21 +0000 From: Harshit Mogalapalli Cc: harshit.m.mogalapalli@oracle.com, error27@gmail.com, dan.carpenter@linaro.org, kernel-janitors@vger.kernel.org, Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , Mukesh Ojha , Douglas Anderson , Akhil P Oommen , Adam Skladowski , Elliot Berman , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH next] drm/msm/a5xx: Fix a NULL dereference bug in a5xx_gpu_init() Date: Mon, 26 Jun 2023 21:12:35 -0700 Message-ID: <20230627041250.3899791-1-harshit.m.mogalapalli@oracle.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-27_01,2023-06-26_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 bulkscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306270039 X-Proofpoint-GUID: yfOpun_fnhTicgyspkhXL1luRak9scc_ X-Proofpoint-ORIG-GUID: yfOpun_fnhTicgyspkhXL1luRak9scc_ 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_H5,RCVD_IN_MSPIKE_WL,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 Smatch complains: drivers/gpu/drm/msm/adreno/a5xx_gpu.c:1753 a5xx_gpu_init() warn: variable dereferenced before check 'pdev' (see line 1746) When no device is defined, dereferencing pdev is a NULL dereference. Fix this by dereferencing pdev to get the config post the NULL check. Fixes: 736a93273656 ("drm/msm/a5xx: really check for A510 in a5xx_gpu_init") Signed-off-by: Harshit Mogalapalli --- This is based on static analysis, only compile tested. --- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c index a99310b68793..adaf8f8e7f2d 100644 --- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c @@ -1743,7 +1743,7 @@ struct msm_gpu *a5xx_gpu_init(struct drm_device *dev) { struct msm_drm_private *priv = dev->dev_private; struct platform_device *pdev = priv->gpu_pdev; - struct adreno_platform_config *config = pdev->dev.platform_data; + struct adreno_platform_config *config; struct a5xx_gpu *a5xx_gpu = NULL; struct adreno_gpu *adreno_gpu; struct msm_gpu *gpu; @@ -1755,6 +1755,8 @@ struct msm_gpu *a5xx_gpu_init(struct drm_device *dev) return ERR_PTR(-ENXIO); } + config = pdev->dev.platform_data; + a5xx_gpu = kzalloc(sizeof(*a5xx_gpu), GFP_KERNEL); if (!a5xx_gpu) return ERR_PTR(-ENOMEM); -- 2.39.3