Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/gem: Document that handle_create must be the last step

It published the gem object to userspace, by that point other threads
can guess the id and start using it. And gem IDs are _very_ easy to
guess (it's just an idr).

Since gem objects is the only thing we allow drivers to create
themselves (all the kms/prime/syncobj stuff is handled by the core) no
other functions seem to be in need of this clarification.

Motivated by reviewing the xen-front kms driver.

Cc: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Reviewed-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180322080233.17266-1-daniel.vetter@ffwll.ch

+6 -3
+6 -3
drivers/gpu/drm/drm_gem.c
··· 436 436 * @obj: object to register 437 437 * @handlep: pionter to return the created handle to the caller 438 438 * 439 - * Create a handle for this object. This adds a handle reference 440 - * to the object, which includes a regular reference count. Callers 441 - * will likely want to dereference the object afterwards. 439 + * Create a handle for this object. This adds a handle reference to the object, 440 + * which includes a regular reference count. Callers will likely want to 441 + * dereference the object afterwards. 442 + * 443 + * Since this publishes @obj to userspace it must be fully set up by this point, 444 + * drivers must call this last in their buffer object creation callbacks. 442 445 */ 443 446 int drm_gem_handle_create(struct drm_file *file_priv, 444 447 struct drm_gem_object *obj,