Skip to contentSkip to conversation

drm: Preload IDR during change_handle

PATCH New David Francis 1 participant 1 message Apr 28

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: Preload IDR during change_handle

change_handle mistakenly had an idr allocation using GFP_NOWAIT without preload. This could lead to idr being unable to allocate needed memory.

Use idr_preload to prevent this (as in create_tail)

---
 drivers/gpu/drm/drm_gem.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/drm_gem.c +4 -0
index 3985def993af..251048d3a3a7 100644
@@ -1039,10 +1039,14 @@ int drm_gem_change_handle_ioctl(struct drm_device *dev, void *data,
 
 	mutex_lock(&file_priv->prime.lock);
 
+	idr_preload(GFP_KERNEL);
 	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);
+	idr_preload_end();
 
 	if (ret < 0)
 		goto out_unlock;
Signature · 1 line
2.34.1