* [PATCH RESEND] drm/vc4: Fix an error code vc4_create_object()
@ 2021-02-25 14:42 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2021-02-25 14:42 UTC (permalink / raw)
To: Eric Anholt; +Cc: David Airlie, Daniel Vetter, dri-devel, kernel-janitors
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 <dan.carpenter@oracle.com>
---
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(-)
diff --git a/drivers/gpu/drm/vc4/vc4_bo.c b/drivers/gpu/drm/vc4/vc4_bo.c
index 72d30d90b856c..0af246a5609ca 100644
--- a/drivers/gpu/drm/vc4/vc4_bo.c
+++ b/drivers/gpu/drm/vc4/vc4_bo.c
@@ -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);
--
2.26.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH RESEND] drm/vc4: Fix an error code vc4_create_object()
@ 2021-02-25 14:42 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2021-02-25 14:42 UTC (permalink / raw)
To: Eric Anholt; +Cc: David Airlie, kernel-janitors, dri-devel
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 <dan.carpenter@oracle.com>
---
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(-)
diff --git a/drivers/gpu/drm/vc4/vc4_bo.c b/drivers/gpu/drm/vc4/vc4_bo.c
index 72d30d90b856c..0af246a5609ca 100644
--- a/drivers/gpu/drm/vc4/vc4_bo.c
+++ b/drivers/gpu/drm/vc4/vc4_bo.c
@@ -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);
--
2.26.2
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH RESEND] drm/vc4: Fix an error code vc4_create_object()
2021-02-25 14:42 ` Dan Carpenter
(?)
@ 2021-02-25 14:57 ` Neil Roberts
-1 siblings, 0 replies; 3+ messages in thread
From: Neil Roberts @ 2021-02-25 14:57 UTC (permalink / raw)
To: Dan Carpenter, Eric Anholt; +Cc: David Airlie, kernel-janitors, dri-devel
Dan Carpenter <dan.carpenter@oracle.com> writes:
> 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 <dan.carpenter@oracle.com>
> ---
> 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(-)
>
> diff --git a/drivers/gpu/drm/vc4/vc4_bo.c b/drivers/gpu/drm/vc4/vc4_bo.c
> index 72d30d90b856c..0af246a5609ca 100644
> --- a/drivers/gpu/drm/vc4/vc4_bo.c
> +++ b/drivers/gpu/drm/vc4/vc4_bo.c
> @@ -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);
Reviewed-by: Neil Roberts <nroberts@igalia.com>
Regards,
- Neil
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-25 14:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-25 14:42 [PATCH RESEND] drm/vc4: Fix an error code vc4_create_object() Dan Carpenter
2021-02-25 14:42 ` Dan Carpenter
2021-02-25 14:57 ` Neil Roberts
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.