On Mon, Jun 22, 2026 at 06:22:27PM +0530, biren pandya wrote:
On Mon, Jun 22, 2026 at 5:25 PM Laurent Pinchart wrote:
On Tue, Jun 16, 2026 at 11:49:57PM +0530, Biren Pandya wrote:
Several GEM core functions manually managed mutex_lock() and mutex_unlock() over single scopes or error paths. This adds boilerplate and carries the risk of lock leaks if error paths are refactored.
Modernize these locks by deploying the <linux/cleanup.h> scoped_guard() macro. This ensures that the locks are reliably dropped when the block exits, cleanly removing goto out_unlock paths and tightening the lifecycle.
What's the reason for doing so in in drm_gem and not other areas in DRM ?
Hi Laurent,
Thanks for taking a look. No deeper reason than it being where I happened to start — I didn't mean to single it out, and I'd rather the treatment be consistent than piecemeal.
@@ -1021,37 +1018,34 @@ int drm_gem_change_handle_ioctl(struct drm_device *dev, void *data, goto out; }
mutex_lock(&file_priv->prime.lock);
scoped_guard(mutex, &file_priv->prime.lock) {spin_lock(&file_priv->table_lock);ret = idr_alloc(&file_priv->object_idr, obj, handle, handle + 1,GFP_NOWAIT);spin_unlock(&file_priv->table_lock);And why don't you use guards for the spinlock as well ?
Fair point — the spinlocks here are equally good candidates; I only kept v1 to mutexes to keep it small.
That said, this is a pure cleanup with no functional change, so it's entirely your call whether it's worth carrying. If you'd like it, I'll send a v2 that converts both the mutexes and the spinlocks in drm_gem.c consistently. If you'd prefer not to take cleanup-only churn, I'm happy to drop it — no problem either way.
I'll let the maintainers of that code decide (I'm not one of them).
linaro-mm-sig@lists.linaro.org