From patchwork Wed Aug 16 22:55:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aravind Vijayakumar X-Patchwork-Id: 13355758 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AEEBFC27C6D for ; Wed, 16 Aug 2023 22:55:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=H4563Skoc3nVkHF9dibH+ExJiaAojmYPVoHogLXhdmI=; b=1ZLC7M7SP2EJZx TNMkPZNfOVdjdnNepeLS4ImNhOkh9gkAJEFvSa3U1xzMzweGhAHoH7pPrDlKCTRwabZREtAZ1WfEs BSHY9PZpbodPTfojV7G8JHyGybNoUBNuvoNQt+oZfE6V6ilNvRx3TtQr2o5ix8/HPu6/svOE72QxJ mrmpuyH/1j8eDv8n3DUCpyfnCI8ldv4sHqu78rH9xeBonfc6lu/LeYWjquZm+8gM3no6BvDlDCB7g pXQC+uNbZ6AitaXjNjbNdYp4FN6Y+moCnZn3ABji864QB/L6xtqiqTUV/QxhHLq7Lh1A3BM+a0Lzz zHCeLteB1OIWWNQcfvYg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qWPQH-0058VY-0c; Wed, 16 Aug 2023 22:55:29 +0000 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qWPQE-0058V9-37 for linux-arm-kernel@lists.infradead.org; Wed, 16 Aug 2023 22:55:28 +0000 Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37GMqJRD013073; Wed, 16 Aug 2023 22:55:15 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-transfer-encoding; s=qcppdkim1; bh=dVUzAjm1YTME2b6hY0E6fQaPmvurh2dNPp4Vd8sQc7c=; b=Xn/W1j7FJsnc7WMVnZ4TbHrR/tYWFfDSmjgFPqCiADR3tokC62EQIO/Ryfx8D4lFdC2K Feu7Y+f7jr62VhlvXLi53kDZW9NKU++ygbu6nOZd8sG1tq6O3uMciU+qjCsK8ZtOBGBm gkmwERLOpPLzsoOiyYacVflCVwtXDWpYEic5Qa5TG5q2ckBpnJ+NV1NOUMmFpSrYEx1r ChDxsJAIpi530MRz1V5fm7FYE8y9gCCQd9clFpFnX0Ut86QNkKJWOtZQnni66lx+Ecm8 KsSfzdh7fPz43hNN08EoY2TlbTLgwB9LF4KT2lqh/d4tFo0Nwtqy+ebriEcEKAv9itly 2w== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3sh2a3gpvk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 16 Aug 2023 22:55:14 +0000 Received: from pps.filterd (NASANPPMTA03.qualcomm.com [127.0.0.1]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 37GMr7VX027860; Wed, 16 Aug 2023 22:55:13 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NASANPPMTA03.qualcomm.com (PPS) with ESMTP id 3sguas73ky-1; Wed, 16 Aug 2023 22:55:13 +0000 Received: from NASANPPMTA03.qualcomm.com (NASANPPMTA03.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 37GMr7Wa027855; Wed, 16 Aug 2023 22:55:13 GMT Received: from car-linux12.qualcomm.com (car-linux12.qualcomm.com [10.62.46.54]) by NASANPPMTA03.qualcomm.com (PPS) with ESMTP id 37GMtDFp030462; Wed, 16 Aug 2023 22:55:13 +0000 Received: by car-linux12.qualcomm.com (Postfix, from userid 2366307) id 52998232B9; Wed, 16 Aug 2023 15:55:13 -0700 (PDT) From: Aravind Vijayakumar To: will@kernel.org, joro@8bytes.org Cc: robin.murphy@arm.com, dmitry.baryshkov@linaro.org, quic_bjorande@quicinc.com, konrad.dybcio@linaro.org, quic_eberman@quicinc.com, robdclark@chromium.org, quic_psodagud@quicinc.com, quic_rvishwak@quicinc.com, quic_saipraka@quicinc.com, quic_molvera@quicinc.com, marijn.suijten@somainline.org, mani@kernel.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, linux-arm-msm@vger.kernel.org, Aravind Vijayakumar Subject: [PATCH] iommu/arm-smmu-qcom: NULL pointer check for driver data Date: Wed, 16 Aug 2023 15:55:09 -0700 Message-Id: <20230816225509.11070-1-quic_aprasann@quicinc.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: QiuLwRKVDeVH3UOJyTe-jdj-s9805Ync X-Proofpoint-ORIG-GUID: QiuLwRKVDeVH3UOJyTe-jdj-s9805Ync X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-16_20,2023-08-15_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 bulkscore=0 clxscore=1011 impostorscore=0 phishscore=0 priorityscore=1501 suspectscore=0 spamscore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308160203 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230816_155527_147522_DC89D55C X-CRM114-Status: GOOD ( 18.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The driver_data is NULL when qcom_adreno_smmu_init_context() is called before the dev_set_drvdata() from the client driver and is resulting in kernel crash. So add a null pointer check to handle the scenario where the client driver for the GPU SMMU device would be setting the driver data after the smmu client device probe is done and not necessarily before that. The function qcom_adreno_smmu_init_context() assumes that the client driver always set the driver data using dev_set_drvdata() before the smmu client device probe, but this assumption is not always true. Signed-off-by: Aravind Vijayakumar --- drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c index c71afda79d64..5323f82264ca 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c @@ -231,6 +231,9 @@ static int qcom_adreno_smmu_init_context(struct arm_smmu_domain *smmu_domain, */ priv = dev_get_drvdata(dev); + if (!priv) + return 0; + priv->cookie = smmu_domain; priv->get_ttbr1_cfg = qcom_adreno_smmu_get_ttbr1_cfg; priv->set_ttbr0_cfg = qcom_adreno_smmu_set_ttbr0_cfg;