drm/msm: Fix potential invalid ptr free
PATCH 1/1 drm/msm: Fix potential invalid ptr free
From: Rob Clark <[email protected]>
The error path cleanup expects that chain and syncobj are either NULL or valid pointers. But post_deps was not allocated with __GFP_ZERO.
--- drivers/gpu/drm/msm/msm_gem_submit.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/msm_gem_submit.c +2 -3
@@ -640,8 +640,8 @@ static struct msm_submit_post_dep *msm_parse_post_deps(struct drm_device *dev,int ret =0 ;uint32_t i, j; - post_deps =kmalloc_array (nr_syncobjs,sizeof (*post_deps), -GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY); + post_deps =kcalloc (nr_syncobjs,sizeof (*post_deps), +GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY);if (!post_deps)return ERR_PTR (-ENOMEM );
@@ -656,7 +656,6 @@ static struct msm_submit_post_dep *msm_parse_post_deps(struct drm_device *dev, } post_deps[i].point = syncobj_desc.point; - post_deps[i].chain =NULL ;if (syncobj_desc.flags) { ret = -EINVAL ;
Signature · 1 line
2.39.1
Quoted 7 lines · Rob Clark
From: Rob Clark <[email protected]>
The error path cleanup expects that chain and syncobj are either NULL or valid pointers. But
post_depswas not allocated with__GFP_ZERO.Fixes ab723b7a992a ("drm/msm: Add syncobj support.")Signed-off-by Rob Clark <[email protected]>
This makes me want to rewrite the ab723b7a992a ("drm/msm: Add syncobj support.") in the usual explicit-error-path way. WDYT?
Quoted 27 lines
--- drivers/gpu/drm/msm/msm_gem_submit.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/gpu/drm/msm/msm_gem_submit.c +2
-3@@ -640,8 +640,8 @@ static struct msm_submit_post_dep *msm_parse_post_deps(struct drm_device *dev,int ret =0 ;uint32_t i, j; - post_deps =kmalloc_array (nr_syncobjs,sizeof (*post_deps), -GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY); + post_deps =kcalloc (nr_syncobjs,sizeof (*post_deps), +GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY);if (!post_deps)return ERR_PTR (-ENOMEM );@@ -656,7 +656,6 @@ static struct msm_submit_post_dep *msm_parse_post_deps(struct drm_device *dev, } post_deps[i].point = syncobj_desc.point; - post_deps[i].chain =NULL ;if (syncobj_desc.flags) { ret = -EINVAL ;
Signature · 2 lines
With best wishes Dmitry
Quoted 27 lines · Rob Clark
From: Rob Clark <[email protected]>
The error path cleanup expects that chain and syncobj are either NULL or valid pointers. But
post_depswas not allocated with__GFP_ZERO.Fixes ab723b7a992a ("drm/msm: Add syncobj support.")Signed-off-by Rob Clark <[email protected]>--- drivers/gpu/drm/msm/msm_gem_submit.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/gpu/drm/msm/msm_gem_submit.c +2
-2@@ -640,8 +640,8 @@ static struct msm_submit_post_dep *msm_parse_post_deps(struct drm_device *dev,int ret =0 ;uint32_t i, j; - post_deps =kmalloc_array (nr_syncobjs,sizeof (*post_deps), -GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY); + post_deps =kcalloc (nr_syncobjs,sizeof (*post_deps), +GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY);if (!post_deps)return ERR_PTR (-ENOMEM );
drivers/gpu/drm/msm/msm_gem_submit.c static struct msm_submit_post_dep *msm_parse_post_deps(struct drm_device *dev, · line 661
Quoted 7 lines
drivers/gpu/drm/msm/msm_gem_submit.c +0
-1@@ -656,7 +656,6 @@ static struct msm_submit_post_dep *msm_parse_post_deps(struct drm_device *dev, } post_deps[i].point = syncobj_desc.point; - post_deps[i].chain =NULL ;if (syncobj_desc.flags) { ret = -EINVAL ;
Good catch!
Signature · 2 lines
Best regards, Dmitry