* [PATCH] drm: re-enable error handling
@ 2018-07-14 12:32 Nicholas Mc Guire
2018-07-16 14:39 ` Sean Paul
0 siblings, 1 reply; 2+ messages in thread
From: Nicholas Mc Guire @ 2018-07-14 12:32 UTC (permalink / raw)
To: Gustavo Padovan
Cc: Maarten Lankhorst, Sean Paul, David Airlie, dri-devel,
linux-kernel, Nicholas Mc Guire
drm_legacy_ctxbitmap_next() returns idr_alloc() which can return
-ENOMEM, -EINVAL or -ENOSPC none of which are -1 . but the call sites
of drm_legacy_ctxbitmap_next() seem to be assuming that the error case
would be -1 (original return of drm_ctxbitmap_next() prior to 2.6.23
was actually -1). Thus reenable error handling by checking for < 0.
Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Fixes: 62968144e673 ("drm: convert drm context code to use Linux idr")
---
Problem located with experimental coccinelle script
The noted Fixes tag is one of the commits that removed the -1 return
value in 2.6.23 in drm_ctxbitmap_next() but thats not the only change
that must have taken place to invalidate the error check.
Patch was compile tested with: x86_64_defconfig
Patch is against 4.18-rc4 (localversion-next is next-20180713)
drivers/gpu/drm/drm_context.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
index 3c4000f..f973d28 100644
--- a/drivers/gpu/drm/drm_context.c
+++ b/drivers/gpu/drm/drm_context.c
@@ -372,7 +372,7 @@ int drm_legacy_addctx(struct drm_device *dev, void *data,
ctx->handle = drm_legacy_ctxbitmap_next(dev);
}
DRM_DEBUG("%d\n", ctx->handle);
- if (ctx->handle == -1) {
+ if (ctx->handle < 0) {
DRM_DEBUG("Not enough free contexts.\n");
/* Should this return -EBUSY instead? */
return -ENOMEM;
--
2.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drm: re-enable error handling
2018-07-14 12:32 [PATCH] drm: re-enable error handling Nicholas Mc Guire
@ 2018-07-16 14:39 ` Sean Paul
0 siblings, 0 replies; 2+ messages in thread
From: Sean Paul @ 2018-07-16 14:39 UTC (permalink / raw)
To: Nicholas Mc Guire
Cc: Gustavo Padovan, Maarten Lankhorst, Sean Paul, David Airlie,
dri-devel, linux-kernel
On Sat, Jul 14, 2018 at 02:32:12PM +0200, Nicholas Mc Guire wrote:
> drm_legacy_ctxbitmap_next() returns idr_alloc() which can return
> -ENOMEM, -EINVAL or -ENOSPC none of which are -1 . but the call sites
> of drm_legacy_ctxbitmap_next() seem to be assuming that the error case
> would be -1 (original return of drm_ctxbitmap_next() prior to 2.6.23
> was actually -1). Thus reenable error handling by checking for < 0.
>
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Thanks for your patch, I've applied it to drm-misc-fixes.
Sean
> Fixes: 62968144e673 ("drm: convert drm context code to use Linux idr")
> ---
>
> Problem located with experimental coccinelle script
>
> The noted Fixes tag is one of the commits that removed the -1 return
> value in 2.6.23 in drm_ctxbitmap_next() but thats not the only change
> that must have taken place to invalidate the error check.
>
> Patch was compile tested with: x86_64_defconfig
>
> Patch is against 4.18-rc4 (localversion-next is next-20180713)
>
> drivers/gpu/drm/drm_context.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
> index 3c4000f..f973d28 100644
> --- a/drivers/gpu/drm/drm_context.c
> +++ b/drivers/gpu/drm/drm_context.c
> @@ -372,7 +372,7 @@ int drm_legacy_addctx(struct drm_device *dev, void *data,
> ctx->handle = drm_legacy_ctxbitmap_next(dev);
> }
> DRM_DEBUG("%d\n", ctx->handle);
> - if (ctx->handle == -1) {
> + if (ctx->handle < 0) {
> DRM_DEBUG("Not enough free contexts.\n");
> /* Should this return -EBUSY instead? */
> return -ENOMEM;
> --
> 2.1.4
>
--
Sean Paul, Software Engineer, Google / Chromium OS
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-07-16 14:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-14 12:32 [PATCH] drm: re-enable error handling Nicholas Mc Guire
2018-07-16 14:39 ` Sean Paul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox