diff --git a/sys/dev/drm2/drm_gem_names.c b/sys/dev/drm2/drm_gem_names.c index 2577d132206..084d50f0478 100644 --- a/sys/dev/drm2/drm_gem_names.c +++ b/sys/dev/drm2/drm_gem_names.c @@ -132,12 +132,12 @@ drm_gem_name_create(struct drm_gem_names *names, void *p, uint32_t *name) { struct drm_gem_name *np; - np = malloc(sizeof(struct drm_gem_name), M_GEM_NAMES, M_WAITOK); - mtx_lock(&names->lock); if (*name != 0) { - mtx_unlock(&names->lock); return (EALREADY); } + + np = malloc(sizeof(struct drm_gem_name), M_GEM_NAMES, M_WAITOK); + mtx_lock(&names->lock); np->name = alloc_unr(names->unr); if (np->name == -1) { mtx_unlock(&names->lock);