Skip to contentSkip to conversation

drm/msm: correct NULL pointer dereference in context_init

PATCH Applied Brian Masney 3 participants 3 messages Jun 27, 2019 – Jul 22, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/msm: correct NULL pointer dereference in context_init

Correct attempted NULL pointer dereference in context_init() when running without an IOMMU.

Fixes 295b22ae596c ("drm/msm: Pass the MMU domain index in struct msm_file_private")

---
The no IOMMU case seems like functionality that we may want to keep based on this comment:
https://elixir.bootlin.com/linux/latest/source/drivers/gpu/drm/msm/adreno/a3xx_gpu.c#L523
Once I get the msm8974 interconnect driver done, I'm going to look into what needs to be done to get the IOMMU working on the Nexus 5.

Alternatively, for development purposes, maybe we could have a NOOP IOMMU driver that would allow us to remove these NULL checks that are sprinkled throughout the code. I haven't looked into this in detail. Thoughts?

 drivers/gpu/drm/msm/msm_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_drv.c +1 -1
index 451bd4508793..83047cb2c735 100644
@@ -619,7 +619,7 @@ static int context_init(struct drm_device *dev, struct drm_file *file)
 
 	msm_submitqueue_init(dev, ctx);
 
-	ctx->aspace = priv->gpu->aspace;
+	ctx->aspace = priv->gpu ? priv->gpu->aspace : NULL;
 	file->driver_priv = ctx;
 
 	return 0;
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Brian Masney

Correct attempted NULL pointer dereference in context_init() when running without an IOMMU.

Fixes 295b22ae596c ("drm/msm: Pass the MMU domain index in struct msm_file_private")

---
The no IOMMU case seems like functionality that we may want to keep based on this comment:
https://elixir.bootlin.com/linux/latest/source/drivers/gpu/drm/msm/adreno/a3xx_gpu.c#L523
Once I get the msm8974 interconnect driver done, I'm going to look into what needs to be done to get the IOMMU working on the Nexus 5.

Quoted 4 lines

Alternatively, for development purposes, maybe we could have a NOOP IOMMU driver that would allow us to remove these NULL checks that are sprinkled throughout the code. I haven't looked into this in detail. Thoughts?

yeah, we probably want to keep !iommu support, it is at least useful for bringup of new (or old) devices. But tends to bitrot a since it isn't a case that gets tested much once iommu is in place. Perhaps there is a way to have a null iommu/aspace, although I'm not quite sure how that would work..

Anyways,

(I guess this can go in via drm-misc-fixes unless we get some more fixes to justify sending msm-fixes MR..)

Quoted 20 lines
 drivers/gpu/drm/msm/msm_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_drv.c +1 -2
index 451bd4508793..83047cb2c735 100644
@@ -619,7 +619,7 @@ static int context_init(struct drm_device *dev, struct drm_file *file)
 
        msm_submitqueue_init(dev, ctx);
 
-       ctx->aspace = priv->gpu->aspace;
+       ctx->aspace = priv->gpu ? priv->gpu->aspace : NULL;
        file->driver_priv = ctx;
 
        return 0;
--

2.20.1

Quoted 4 lines

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno

reviewer Applied
#2 lore raw
Quoted 25 lines · Rob Clark
Quoted 13 lines · Brian Masney

Correct attempted NULL pointer dereference in context_init() when running without an IOMMU.

Fixes 295b22ae596c ("drm/msm: Pass the MMU domain index in struct msm_file_private")

---
The no IOMMU case seems like functionality that we may want to keep based on this comment:
https://elixir.bootlin.com/linux/latest/source/drivers/gpu/drm/msm/adreno/a3xx_gpu.c#L523
Once I get the msm8974 interconnect driver done, I'm going to look into what needs to be done to get the IOMMU working on the Nexus 5.

Quoted 4 lines

Alternatively, for development purposes, maybe we could have a NOOP IOMMU driver that would allow us to remove these NULL checks that are sprinkled throughout the code. I haven't looked into this in detail. Thoughts?

yeah, we probably want to keep !iommu support, it is at least useful for bringup of new (or old) devices. But tends to bitrot a since it isn't a case that gets tested much once iommu is in place. Perhaps there is a way to have a null iommu/aspace, although I'm not quite sure how that would work..

Quoted 6 lines

Anyways,

(I guess this can go in via drm-misc-fixes unless we get some more fixes to justify sending msm-fixes MR..)

Applied to drm-misc-fixes for 5.3

Sean

Quoted 25 lines
Quoted 25 lines

 drivers/gpu/drm/msm/msm_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_drv.c +1 -2
index 451bd4508793..83047cb2c735 100644
@@ -619,7 +619,7 @@ static int context_init(struct drm_device *dev, struct drm_file *file)
 
        msm_submitqueue_init(dev, ctx);
 
-       ctx->aspace = priv->gpu->aspace;
+       ctx->aspace = priv->gpu ? priv->gpu->aspace : NULL;
        file->driver_priv = ctx;
 
        return 0;
--

2.20.1

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno

Signature · 5 lines
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel