drm/msm/adreno/a5xx_debugfs: fix potential NULL pointer dereference
Subsystems (4)
PATCH 1/1 drm/msm/adreno/a5xx_debugfs: fix potential NULL pointer dereference
_minor_ is being dereferenced before it is null checked, hence there is a potential null pointer dereference. Fix this by moving the pointer dereference after _minor_ has been null checked.
---
I wonder if a better solution for this would be to WARN_ON in case _minor_ happens to be NULL and return -EINVAL, instead of just returning zero.
Something like:
struct drm_device *dev;
if (WARN_ON(!minor)
return -EINVAL;
dev = minor->dev;
What do you think?
Thanks
drivers/gpu/drm/msm/adreno/a5xx_debugfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a5xx_debugfs.c +3 -1
@@ -159,13 +159,15 @@ DEFINE_SIMPLE_ATTRIBUTE(reset_fops, NULL, reset_set, "%llx\n");int a5xx_debugfs_init (struct msm_gpu *gpu,struct drm_minor *minor) { -struct drm_device *dev = minor->dev; +struct drm_device *dev;struct dentry *ent;int ret;if (!minor)return 0 ; + dev = minor->dev; + ret =drm_debugfs_create_files (a5xx_debugfs_list,ARRAY_SIZE (a5xx_debugfs_list), minor->debugfs_root, minor);
Signature · 1 line
2.7.4
Quoted 13 lines · Gustavo A. R. Silva
_minor_ is being dereferenced before it is null checked, hence there is a potential null pointer dereference. Fix this by moving the pointer dereference after _minor_ has been null checked.
Fixes 024ad8df763f ("drm/msm: add a5xx specific debugfs")Signed-off-by Gustavo A. R. Silva <[email protected]>---
I wonder if a better solution for this would be to
WARN_ONin case _minor_ happens to be NULL and return-EINVAL, instead of just returning zero.Something like:
Quoted 8 lines
struct
drm_device*dev;if (
WARN_ON(!minor)return -EINVAL;dev =
minor->dev;What do you think?
In my opinion everything in debugfs is optional. I'm not sure if it is even possible for dev->primary, dev->render or dev->control to be NULL from the DRM core but if so I think the failure should be silent.
Jordan
Quoted 32 lines
drivers/gpu/drm/msm/adreno/a5xx_debugfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/msm/adreno/a5xx_debugfs.c +3
-1@@ -159,13 +159,15 @@ DEFINE_SIMPLE_ATTRIBUTE(reset_fops, NULL, reset_set, "%llx\n");int a5xx_debugfs_init (struct msm_gpu *gpu,struct drm_minor *minor) { -struct drm_device *dev = minor->dev; +struct drm_device *dev;struct dentry *ent;int ret;if (!minor)return 0 ; + dev = minor->dev; + ret =drm_debugfs_create_files (a5xx_debugfs_list,ARRAY_SIZE (a5xx_debugfs_list), minor->debugfs_root, minor);Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 6 lines
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 19 lines · Jordan Crouse
Quoted 18 lines · Gustavo A. R. Silva
_minor_ is being dereferenced before it is null checked, hence there is a potential null pointer dereference. Fix this by moving the pointer dereference after _minor_ has been null checked.
Fixes 024ad8df763f ("drm/msm: add a5xx specific debugfs")Signed-off-by Gustavo A. R. Silva <[email protected]>---
I wonder if a better solution for this would be to
WARN_ONin case _minor_ happens to be NULL and return-EINVAL, instead of just returning zero.Something like:
struct
drm_device*dev;if (
WARN_ON(!minor)return -EINVAL;
Quoted 8 lines
Quoted 3 lines
dev =
minor->dev;What do you think?
In my opinion everything in debugfs is optional. I'm not sure if it is even possible for
dev->primary,dev->renderordev->controlto be NULL from the DRM core but if so I think the failure should be silent.
Don't have code in front of me atm, but I think this is one of those things you can hit both before and after we have the minor, depending on whether filesystem and fw are present when the driver loads or not.. so I don't think it should be a WARN_ON().
BR,
-R
Quoted 29 lines
Jordan
Quoted 28 lines
drivers/gpu/drm/msm/adreno/a5xx_debugfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/msm/adreno/a5xx_debugfs.c +3
-2@@ -159,13 +159,15 @@ DEFINE_SIMPLE_ATTRIBUTE(reset_fops, NULL, reset_set, "%llx\n");int a5xx_debugfs_init (struct msm_gpu *gpu,struct drm_minor *minor) { -struct drm_device *dev = minor->dev; +struct drm_device *dev;struct dentry *ent;int ret;if (!minor)return 0 ; + dev = minor->dev; + ret =drm_debugfs_create_files (a5xx_debugfs_list,ARRAY_SIZE (a5xx_debugfs_list), minor->debugfs_root, minor); --2.7.4
Quoted 8 lines
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno
Quoting Rob Clark <[email protected]>:
Quoted 29 lines · Jordan Crouse
Quoted 19 lines · Gustavo A. R. Silva
Quoted 18 lines
_minor_ is being dereferenced before it is null checked, hence there is a potential null pointer dereference. Fix this by moving the pointer dereference after _minor_ has been null checked.
Fixes 024ad8df763f ("drm/msm: add a5xx specific debugfs")Signed-off-by Gustavo A. R. Silva <[email protected]>---
I wonder if a better solution for this would be to
WARN_ONin case _minor_ happens to be NULL and return-EINVAL, instead of just returning zero.Something like:
struct
drm_device*dev;if (
WARN_ON(!minor)return -EINVAL;Quoted 8 lines
Quoted 3 lines
dev =
minor->dev;What do you think?
In my opinion everything in debugfs is optional. I'm not sure if it is even possible for
dev->primary,dev->renderordev->controlto be NULL from the DRM core but if so I think the failure should be silent.
Quoted 5 lines
Don't have code in front of me atm, but I think this is one of those things you can hit both before and after we have the minor, depending on whether filesystem and fw are present when the driver loads or not.. so I don't think it should be a
WARN_ON().
I get it. Then in this case this patch should work just fine.
Thank you both Jordan and Rob for the feedback.
--
Gustavo
Quoted 42 lines
BR,
-RQuoted 38 lines
Jordan
Quoted 26 lines
drivers/gpu/drm/msm/adreno/a5xx_debugfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/msm/adreno/a5xx_debugfs.c +3
-1@@ -159,13 +159,15 @@ DEFINE_SIMPLE_ATTRIBUTE(reset_fops, NULL, reset_set, "%llx\n");int a5xx_debugfs_init (struct msm_gpu *gpu,struct drm_minor *minor) { -struct drm_device *dev = minor->dev; +struct drm_device *dev;struct dentry *ent;int ret;if (!minor)return 0 ; + dev = minor->dev; + ret = drm_debugfs_create_files(a5xx_debugfs_list, ARRAY_SIZE(a5xx_debugfs_list),minor->debugfs_root, minor);Quoted 7 lines
--
2.7.4--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno