[bug report] drm: re-enable error handling

Dan Carpenter dan.carpenter at oracle.com
Thu Jul 19 08:10:30 UTC 2018


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


More information about the dri-devel mailing list