drm/vc4: Fix an error code vc4_create_object()
Subsystems (4)
PATCH RESEND 1/1 drm/vc4: Fix an error code vc4_create_object()
The vc4_create_object() needs to return NULL on error, not error pointers. If it returns an error pointer then that will lead to an Oops in the callers. Fortunately, in current kernels small allocations always succed so this will never happen.
---
I sent this patch last June but it was never applied.
drivers/gpu/drm/vc4/vc4_bo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_bo.c +1 -1
@@ -389,7 +389,7 @@ struct drm_gem_object *vc4_create_object(struct drm_device *dev, size_t size) bo =kzalloc (sizeof (*bo),GFP_KERNEL );if (!bo) -return ERR_PTR (-ENOMEM ); +return NULL ; bo->madv =VC4_MADV_WILLNEED ;refcount_set (&bo->usecnt,0 );
Signature · 5 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 18 lines · Dan Carpenter
The
vc4_create_object()needs to return NULL on error, not error pointers. If it returns an error pointer then that will lead to an Oops in the callers. Fortunately, in current kernels small allocations always succed so this will never happen.Fixes c826a6e10644 ("drm/vc4: Add a BO cache.")Signed-off-by Dan Carpenter <[email protected]>---
I sent this patch last June but it was never applied.drivers/gpu/drm/vc4/vc4_bo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/vc4/vc4_bo.c +0
-0
drivers/gpu/drm/vc4/vc4_bo.c struct drm_gem_object *vc4_create_object(struct drm_device *dev, size_t size) · line 392
Quoted 5 lines
drivers/gpu/drm/vc4/vc4_bo.c +1
-1@@ -389,7 +389,7 @@ struct drm_gem_object *vc4_create_object(struct drm_device *dev, size_t size) bo =kzalloc (sizeof (*bo),GFP_KERNEL );if (!bo) -return ERR_PTR (-ENOMEM ); +return NULL ;
This change looks right to me. For reference, the code that calls it looks like this:
if (drm->driver->gem_create_object)
gem_obj = drm->driver->gem_create_object(drm, size);
/* … */
if (!gem_obj)
return ERR_PTR(-ENOMEM);Regards,
- Neil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel