Message ID | 20240628145536.778349-2-boris.brezillon@collabora.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/panthor: Fix support for sync-only jobs | expand |
On Fri, Jun 28, 2024 at 04:55:35PM +0200, Boris Brezillon wrote: > The user is likely to leave all the drm_panthor_obj_array fields > to zero when the array is empty, which will cause an EINVAL failure. > > Fixes: 4bdca1150792 ("drm/panthor: Add the driver frontend block") > Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Liviu Dudau <liviu.dudau@arm.com> Best regards, Liviu > --- > drivers/gpu/drm/panthor/panthor_drv.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c > index b8a84f26b3ef..b5e7b919f241 100644 > --- a/drivers/gpu/drm/panthor/panthor_drv.c > +++ b/drivers/gpu/drm/panthor/panthor_drv.c > @@ -86,15 +86,15 @@ panthor_get_uobj_array(const struct drm_panthor_obj_array *in, u32 min_stride, > int ret = 0; > void *out_alloc; > > + if (!in->count) > + return NULL; > + > /* User stride must be at least the minimum object size, otherwise it might > * lack useful information. > */ > if (in->stride < min_stride) > return ERR_PTR(-EINVAL); > > - if (!in->count) > - return NULL; > - > out_alloc = kvmalloc_array(in->count, obj_size, GFP_KERNEL); > if (!out_alloc) > return ERR_PTR(-ENOMEM); > -- > 2.45.0 >
On 28/06/2024 15:55, Boris Brezillon wrote: > The user is likely to leave all the drm_panthor_obj_array fields > to zero when the array is empty, which will cause an EINVAL failure. > > Fixes: 4bdca1150792 ("drm/panthor: Add the driver frontend block") > Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Steven Price <steven.price@arm.com> > --- > drivers/gpu/drm/panthor/panthor_drv.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c > index b8a84f26b3ef..b5e7b919f241 100644 > --- a/drivers/gpu/drm/panthor/panthor_drv.c > +++ b/drivers/gpu/drm/panthor/panthor_drv.c > @@ -86,15 +86,15 @@ panthor_get_uobj_array(const struct drm_panthor_obj_array *in, u32 min_stride, > int ret = 0; > void *out_alloc; > > + if (!in->count) > + return NULL; > + > /* User stride must be at least the minimum object size, otherwise it might > * lack useful information. > */ > if (in->stride < min_stride) > return ERR_PTR(-EINVAL); > > - if (!in->count) > - return NULL; > - > out_alloc = kvmalloc_array(in->count, obj_size, GFP_KERNEL); > if (!out_alloc) > return ERR_PTR(-ENOMEM);
diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c index b8a84f26b3ef..b5e7b919f241 100644 --- a/drivers/gpu/drm/panthor/panthor_drv.c +++ b/drivers/gpu/drm/panthor/panthor_drv.c @@ -86,15 +86,15 @@ panthor_get_uobj_array(const struct drm_panthor_obj_array *in, u32 min_stride, int ret = 0; void *out_alloc; + if (!in->count) + return NULL; + /* User stride must be at least the minimum object size, otherwise it might * lack useful information. */ if (in->stride < min_stride) return ERR_PTR(-EINVAL); - if (!in->count) - return NULL; - out_alloc = kvmalloc_array(in->count, obj_size, GFP_KERNEL); if (!out_alloc) return ERR_PTR(-ENOMEM);
The user is likely to leave all the drm_panthor_obj_array fields to zero when the array is empty, which will cause an EINVAL failure. Fixes: 4bdca1150792 ("drm/panthor: Add the driver frontend block") Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> --- drivers/gpu/drm/panthor/panthor_drv.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)