Skip to contentSkip to conversation

drm: re-enable error handling

bug report Dan Carpenter 2 participants 2 messages Jul 19, 2018

lore
Share & tools
lore
#0 lore raw

Hello Nicholas Mc Guire,

The patch d530b5f1ca0b: "drm: re-enable error handling" from Jul 14, 2018, leads to the following static checker warning:

	drivers/gpu/drm/drm_context.c:375 drm_legacy_addctx()
	warn: unsigned 'ctx->handle' is never less than zero.

drivers/gpu/drm/drm_context.c
359 int drm_legacy_addctx(struct drm_device *dev, void *data,
360 struct drm_file *file_priv)
361 {
362 struct drm_ctx_list *ctx_entry;
363 struct drm_ctx *ctx = data;
364
365 if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
366 !drm_core_check_feature(dev, DRIVER_LEGACY))
367 return -EINVAL;
368
369 ctx->handle = drm_legacy_ctxbitmap_next(dev);
370 if (ctx->handle == DRM_KERNEL_CONTEXT) {
371 /* Skip kernel's context and get a new one. */
372 ctx->handle = drm_legacy_ctxbitmap_next(dev);

   373          }
   374          DRM_DEBUG("%d\n", ctx->handle);
   375          if (ctx->handle < 0) {
                    ^^^^^^^^^^^^^^^

This can't be true.

   376                  DRM_DEBUG("Not enough free contexts.\n");
   377                  /* Should this return -EBUSY instead? */
   378                  return -ENOMEM;

379 }

regards,
dan carpenter
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#1 lore raw
Quoted 27 lines · Dan Carpenter

Hello Nicholas Mc Guire,

The patch d530b5f1ca0b: "drm: re-enable error handling" from Jul 14, 2018, leads to the following static checker warning:

	drivers/gpu/drm/drm_context.c:375 drm_legacy_addctx()
	warn: unsigned 'ctx->handle' is never less than zero.

drivers/gpu/drm/drm_context.c
359 int drm_legacy_addctx(struct drm_device *dev, void *data,
360 struct drm_file *file_priv)

   361  {
   362          struct drm_ctx_list *ctx_entry;
   363          struct drm_ctx *ctx = data;
   364  
   365          if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
   366              !drm_core_check_feature(dev, DRIVER_LEGACY))
   367                  return -EINVAL;
   368  
   369          ctx->handle = drm_legacy_ctxbitmap_next(dev);
   370          if (ctx->handle == DRM_KERNEL_CONTEXT) {
   371                  /* Skip kernel's context and get a new one. */
   372                  ctx->handle = drm_legacy_ctxbitmap_next(dev);
   373          }
   374          DRM_DEBUG("%d\n", ctx->handle);
   375          if (ctx->handle < 0) {
                    ^^^^^^^^^^^^^^^
Quoted 1 line

This can't be true.

yup this was also reported by kbuild test robot <[email protected]> and (hopfully correctly) fixed in [PATCH V3] drm: handle error values properly see http://lkml.org/lkml/2018/7/18/191

thx!
hofrat

Quoted 8 lines
   376                  DRM_DEBUG("Not enough free contexts.\n");
   377                  /* Should this return -EBUSY instead? */
   378                  return -ENOMEM;

379 }

regards,
dan carpenter

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel