From patchwork Sat Dec 3 22:41:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil P Oommen X-Patchwork-Id: 29346 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1550564wrr; Sat, 3 Dec 2022 14:43:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf76/+sAUYiHyajPM1yjVrebxKcIRI0YFr4nYJcu3G73cawQ41KSoBhqE8Ffi8jQs0jWP9a0 X-Received: by 2002:a17:906:6dd5:b0:78d:a633:b55 with SMTP id j21-20020a1709066dd500b0078da6330b55mr67561650ejt.106.1670107388651; Sat, 03 Dec 2022 14:43:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670107388; cv=none; d=google.com; s=arc-20160816; b=ZVHcF2IBqrN2q+KR6NZZR7b0cTHPxILt+wzoYcOwjSQOqDvrJ8CdwlTZLVJCyBvVm7 9VM18XF2vKLZmStJQVupP91/8/B4xVoGvq5DkqJE4bG/T+1TtWogjQvft9z6cu5NIJnV MwGUZ8Ug9Zaa3XhkdK0DlYfmdgkfoLsOf+RMwzw1q69V3KdcyZZm04YHiXrcj+NAM0pa SAH9uYxbmqE7Xdr/Ii7cthUDavw1s6R6O8DTQgBsG5MVetVNbGc1F8NIVZ+p4jVb3tv/ KkPKFnrqkYkc3gC8YQ03kW7ZffH56+Fo1aX7PDG0sopoQ+AmG2uhyUZoMHqYXnRs9w37 uKLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=1720mK3ENuwblwaixmKXbdKP6GzFCMbgPkajMRDFOYE=; b=idiMzFICCfnqhJHvRL/ofEp7niuiZn1w6ktGSpDn/fcpbOcgwPXbw2RFe3SSohmJIN vnAcGetGLhd7pmukiRGHpR7WR0oUPLx0ER01SWd70D6gZQ3UMS7+nCvXTECAj55E0Iqd SRhBCiZCbHBQdNr3vD0JW6PdQ1LgIVFFMDpEayFtRGNa/eEHGOdYP5E9bfxr3xtRiIdX UoqNA9VqP4R8DAXAQjZrebz7XvQl7hgKTETdvraItQS8vO1TyM2kkq02Ss2JUbOUF0HH dxbP5/s+Tn8OAd7/ma+drmIYQPO9BNm4Yt7302WYk3tBPR+E0Vcq5eA6fMGujDcsJewt b97w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=WS0VJ8Br; 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=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hd19-20020a170907969300b007ae63fe980dsi10610568ejc.931.2022.12.03.14.42.42; Sat, 03 Dec 2022 14:43:08 -0800 (PST) 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=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=WS0VJ8Br; 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=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229778AbiLCWmJ (ORCPT + 99 others); Sat, 3 Dec 2022 17:42:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229503AbiLCWmI (ORCPT ); Sat, 3 Dec 2022 17:42:08 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F24641B9EE; Sat, 3 Dec 2022 14:42:06 -0800 (PST) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B3MfMqg007991; Sat, 3 Dec 2022 22:42:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=qcppdkim1; bh=1720mK3ENuwblwaixmKXbdKP6GzFCMbgPkajMRDFOYE=; b=WS0VJ8BrPUcRUSoaa3uKvlBGmbmTDUrVansCyW6562iu6DgrDuJKM9eL9xy5d3OSitp0 uuG1cm13bDSXfYOjVcQe0g7kxDLScBLr0/hip5Y3p4vtIWIFF0iENYpfQCkJmD2GABfy J+7hjO+HBAy6jc5Eap7qP37D7lajyHtmGnDt9YkWzvNKfy6hy/FeT+gLzaqapFgs1eUg cHHyIGXOpJ6hLUdym/ltnRZ77FJokIc1c1LC0+jckd3cb6PcgTLJ9C8pGBYX2fZyC/w5 P4jhSZbwT9C06eK3ZLJCgFXtXDtMPQ4LxBBdporpQ+H9FvcnQKvtpbMhu6gUTsBWDgHZ rw== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3m7xj0h7ck-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 03 Dec 2022 22:42:02 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2B3Mg12i004758 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 3 Dec 2022 22:42:01 GMT Received: from hyd-lnxbld559.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Sat, 3 Dec 2022 14:41:57 -0800 From: Akhil P Oommen To: freedreno , , CC: Akhil P Oommen , Abhinav Kumar , Dan Carpenter , Daniel Vetter , David Airlie , Dmitry Baryshkov , Emma Anholt , Rob Clark , Sean Paul , Subject: [PATCH 1/4] drm/msm/adreno: Fix null ptr access in adreno_gpu_cleanup() Date: Sun, 4 Dec 2022 04:11:41 +0530 Message-ID: <20221204040946.1.Ib978de92c4bd000b515486aad72e96c2481f84d0@changeid> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: teh7lf8t4F_5LQd-wwBoXhm5_q29eTJG X-Proofpoint-ORIG-GUID: teh7lf8t4F_5LQd-wwBoXhm5_q29eTJG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-03_12,2022-12-01_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 mlxlogscore=999 clxscore=1011 impostorscore=0 adultscore=0 malwarescore=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212030202 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751234525221477220?= X-GMAIL-MSGID: =?utf-8?q?1751234525221477220?= Fix the below kernel panic due to null pointer access: [ 18.504431] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000048 [ 18.513464] Mem abort info: [ 18.516346] ESR = 0x0000000096000005 [ 18.520204] EC = 0x25: DABT (current EL), IL = 32 bits [ 18.525706] SET = 0, FnV = 0 [ 18.528878] EA = 0, S1PTW = 0 [ 18.532117] FSC = 0x05: level 1 translation fault [ 18.537138] Data abort info: [ 18.540110] ISV = 0, ISS = 0x00000005 [ 18.544060] CM = 0, WnR = 0 [ 18.547109] user pgtable: 4k pages, 39-bit VAs, pgdp=0000000112826000 [ 18.553738] [0000000000000048] pgd=0000000000000000, p4d=0000000000000000, pud=0000000000000000 [ 18.562690] Internal error: Oops: 0000000096000005 [#1] PREEMPT SMP **Snip** [ 18.696758] Call trace: [ 18.699278] adreno_gpu_cleanup+0x30/0x88 [ 18.703396] a6xx_destroy+0xc0/0x130 [ 18.707066] a6xx_gpu_init+0x308/0x424 [ 18.710921] adreno_bind+0x178/0x288 [ 18.714590] component_bind_all+0xe0/0x214 [ 18.718797] msm_drm_bind+0x1d4/0x614 [ 18.722566] try_to_bring_up_aggregate_device+0x16c/0x1b8 [ 18.728105] __component_add+0xa0/0x158 [ 18.732048] component_add+0x20/0x2c [ 18.735719] adreno_probe+0x40/0xc0 [ 18.739300] platform_probe+0xb4/0xd4 [ 18.743068] really_probe+0xfc/0x284 [ 18.746738] __driver_probe_device+0xc0/0xec [ 18.751129] driver_probe_device+0x48/0x110 [ 18.755421] __device_attach_driver+0xa8/0xd0 [ 18.759900] bus_for_each_drv+0x90/0xdc [ 18.763843] __device_attach+0xfc/0x174 [ 18.767786] device_initial_probe+0x20/0x2c [ 18.772090] bus_probe_device+0x40/0xa0 [ 18.776032] deferred_probe_work_func+0x94/0xd0 [ 18.780686] process_one_work+0x190/0x3d0 [ 18.784805] worker_thread+0x280/0x3d4 [ 18.788659] kthread+0x104/0x1c0 [ 18.791981] ret_from_fork+0x10/0x20 [ 18.795654] Code: f9400408 aa0003f3 aa1f03f4 91142015 (f9402516) [ 18.801913] ---[ end trace 0000000000000000 ]--- [ 18.809039] Kernel panic - not syncing: Oops: Fatal exception Signed-off-by: Akhil P Oommen --- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c index 382fb7f9e497..118d07e5c66c 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c @@ -1073,13 +1073,13 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, void adreno_gpu_cleanup(struct adreno_gpu *adreno_gpu) { struct msm_gpu *gpu = &adreno_gpu->base; - struct msm_drm_private *priv = gpu->dev->dev_private; + struct msm_drm_private *priv = gpu->dev ? gpu->dev->dev_private : NULL; unsigned int i; for (i = 0; i < ARRAY_SIZE(adreno_gpu->info->fw); i++) release_firmware(adreno_gpu->fw[i]); - if (pm_runtime_enabled(&priv->gpu_pdev->dev)) + if (priv && pm_runtime_enabled(&priv->gpu_pdev->dev)) pm_runtime_disable(&priv->gpu_pdev->dev); msm_gpu_cleanup(&adreno_gpu->base);