Skip to contentSkip to conversation

drm/gem: Remove unneeded ret check in change handle ioctl

PATCH In review Jonathan Cavitt 2 participants 3 messages May 11 – May 14

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

PATCH 1/1 drm/gem: Remove unneeded ret check in change handle ioctl

Remove the "if (ret < 0)" branch after idr_replace in drm_gem_change_handle_ioctl. It is unused, as in the only place we modify the return value between there and the previous return value check, we also immediately jump to out_unlock, bypassing the check entirely.

Issue caught by static analysis.

Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Thomas Zimmermann <[email protected]>
Cc David Airlie <[email protected]>
Cc Simona Vetter <[email protected]>
---
 drivers/gpu/drm/drm_gem.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/gpu/drm/drm_gem.c +0 -3
index abc8e41d6652..110bc5a58862 100644
@@ -1067,9 +1067,6 @@ int drm_gem_change_handle_ioctl(struct drm_device *dev, void *data,
 
 	spin_unlock(&file_priv->table_lock);
 
-	if (ret < 0)
-		goto out_unlock;
-
 	if (obj->dma_buf) {
 		ret = drm_prime_add_buf_handle(&file_priv->prime, obj->dma_buf,
 					       handle);
Signature · 1 line
2.53.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Jonathan Cavitt

Remove the "if (ret < 0)" branch after idr_replace in drm_gem_change_handle_ioctl. It is unused, as in the only place we modify the return value between there and the previous return value check, we also immediately jump to out_unlock, bypassing the check entirely.

Issue caught by static analysis.

Quoted 28 lines
Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Thomas Zimmermann <[email protected]>
Cc David Airlie <[email protected]>
Cc Simona Vetter <[email protected]>
---
 drivers/gpu/drm/drm_gem.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/gpu/drm/drm_gem.c +0 -3
index abc8e41d6652..110bc5a58862 100644
@@ -1067,9 +1067,6 @@ int drm_gem_change_handle_ioctl(struct drm_device *dev, void *data,
 
 	spin_unlock(&file_priv->table_lock);
 
-	if (ret < 0)
-		goto out_unlock;
-
 	if (obj->dma_buf) {
 		ret = drm_prime_add_buf_handle(&file_priv->prime, obj->dma_buf,
 					       handle);
Signature · 1 line
2.53.0
#2 lore raw
Quoted 10 lines · Rodrigo Vivi
Quoted 7 lines · Jonathan Cavitt

Remove the "if (ret < 0)" branch after idr_replace in drm_gem_change_handle_ioctl. It is unused, as in the only place we modify the return value between there and the previous return value check, we also immediately jump to out_unlock, bypassing the check entirely.

Issue caught by static analysis.

It doesn't apply in drm-misc branches yet because it doesn't yet have the culprit patch that caused this code.

That is only part of drm-fixes:

5e28b7b94408 ("drm: Set old handle to NULL before prime swap in change_handle")

I believe this patch here can wait this culprit patch to get propagated through a backmerge/rebase...

Quoted 29 lines
Quoted 29 lines
Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Thomas Zimmermann <[email protected]>
Cc David Airlie <[email protected]>
Cc Simona Vetter <[email protected]>
---
 drivers/gpu/drm/drm_gem.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/gpu/drm/drm_gem.c +0 -3
index abc8e41d6652..110bc5a58862 100644
@@ -1067,9 +1067,6 @@ int drm_gem_change_handle_ioctl(struct drm_device *dev, void *data,
 
 	spin_unlock(&file_priv->table_lock);
 
-	if (ret < 0)
-		goto out_unlock;
-
 	if (obj->dma_buf) {
 		ret = drm_prime_add_buf_handle(&file_priv->prime, obj->dma_buf,
 					       handle);
Signature · 1 line
2.53.0