Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
* [PATCH] iommu/arm-smmu-qcom: NULL pointer check for driver data
@ 2023-08-16 22:55 Aravind Vijayakumar
  2023-08-17  1:01 ` Rob Clark
  0 siblings, 1 reply; 8+ messages in thread
From: Aravind Vijayakumar @ 2023-08-16 22:55 UTC (permalink / raw)
  To: will, joro
  Cc: robin.murphy, dmitry.baryshkov, quic_bjorande, konrad.dybcio,
	quic_eberman, robdclark, quic_psodagud, quic_rvishwak,
	quic_saipraka, quic_molvera, marijn.suijten, mani,
	linux-arm-kernel, iommu, linux-arm-msm, Aravind Vijayakumar

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 <quic_aprasann@quicinc.com>
---
 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;
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-09-15 10:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-16 22:55 [PATCH] iommu/arm-smmu-qcom: NULL pointer check for driver data Aravind Vijayakumar
2023-08-17  1:01 ` Rob Clark
2023-08-28 21:35   ` Aravind Vijayakumar
2023-08-29 14:30     ` Rob Clark
2023-09-08  5:17       ` Aravind Vijayakumar
2023-09-08 12:21         ` Robin Murphy
2023-09-15  0:20           ` Aravind Vijayakumar
2023-09-15 10:08             ` Robin Murphy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox