Skip to contentSkip to conversation

drm/lease: fix WARNING in idr_destroy

PATCH Superseded Qiujun Huang 2 participants 3 messages Mar 16, 2020 – Mar 17, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/lease: fix WARNING in idr_destroy

leases has been destroyed:
drm_master_put

    ->drm_master_destroy
            ->idr_destroy

so the "out_lessee" needn't to call idr_destroy again.

Reported-and-tested-by [email protected]
---
 drivers/gpu/drm/drm_lease.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_lease.c +4 -1
index b481caf..54506c2 100644
@@ -577,11 +577,14 @@ int drm_mode_create_lease_ioctl(struct drm_device *dev,
 
 out_lessee:
 	drm_master_put(&lessee);
+	goto err_exit;
 
 out_leases:
-	put_unused_fd(fd);
 	idr_destroy(&leases);
 
+err_exit:
+	put_unused_fd(fd);
+
 	DRM_DEBUG_LEASE("drm_mode_create_lease_ioctl failed: %d\n", ret);
 	return ret;
 }
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 18 lines · Qiujun Huang

leases has been destroyed:
drm_master_put

    ->drm_master_destroy
            ->idr_destroy

so the "out_lessee" needn't to call idr_destroy again.

Reported-and-tested-by [email protected]
---
 drivers/gpu/drm/drm_lease.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_lease.c +0 -0
index b481caf..54506c2 100644

drivers/gpu/drm/drm_lease.c int drm_mode_create_lease_ioctl(struct drm_device *dev, · line 580

Quoted 4 lines
drivers/gpu/drm/drm_lease.c +1 -0
@@ -577,11 +577,14 @@ int drm_mode_create_lease_ioctl(struct drm_device *dev,
 
 out_lessee:
 	drm_master_put(&lessee);
+	goto err_exit;

I think this is correct, but also confusioning and inconsistent with the existing style. Most error cases before drm_lease_create explicit destroy the idr, except the one for drm_lease_create.

Instead of your patch I'd
- remove the idr_destry from the error unrolling here
- add it the to drm_lease_create error case
- add a comment above the call to drm_lease_crete that it takes ownership of the lease idr

Can you pls respin and retest to make sure that patch is still correct?

Thanks, Daniel

Quoted 14 lines
drivers/gpu/drm/drm_lease.c +3 -1
 out_leases:
-	put_unused_fd(fd);
 	idr_destroy(&leases);
 
+err_exit:
+	put_unused_fd(fd);
+
 	DRM_DEBUG_LEASE("drm_mode_create_lease_ioctl failed: %d\n", ret);
 	return ret;
 }
Signature · 1 line
1.8.3.1
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw
Quoted 21 lines · Daniel Vetter
Quoted 19 lines · Qiujun Huang

leases has been destroyed:
drm_master_put

    ->drm_master_destroy
            ->idr_destroy

so the "out_lessee" needn't to call idr_destroy again.

Reported-and-tested-by [email protected]
---
 drivers/gpu/drm/drm_lease.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_lease.c +0 -0
index b481caf..54506c2 100644
@@ -577,11 +577,14 @@ int drm_mode_create_lease_ioctl(struct drm_device *dev,
 
Quoted 7 lines

drivers/gpu/drm/drm_lease.c int drm_mode_create_lease_ioctl(struct drm_device *dev, · line 580

Quoted 3 lines
drivers/gpu/drm/drm_lease.c +1 -0
 out_lessee:
      drm_master_put(&lessee);
+     goto err_exit;

I think this is correct, but also confusioning and inconsistent with the existing style. Most error cases before drm_lease_create explicit destroy the idr, except the one for drm_lease_create.

Yeah, it is.

Quoted 8 lines

Instead of your patch I'd
- remove the idr_destry from the error unrolling here
- add it the to drm_lease_create error case
- add a comment above the call to drm_lease_crete that it takes ownership of the lease idr

Can you pls respin and retest to make sure that patch is still correct?

I get that, thanks.

Quoted 22 lines

Thanks, Daniel

Quoted 12 lines
drivers/gpu/drm/drm_lease.c +3 -2
 out_leases:
-     put_unused_fd(fd);
      idr_destroy(&leases);
 
+err_exit:
+     put_unused_fd(fd);
+
      DRM_DEBUG_LEASE("drm_mode_create_lease_ioctl failed: %d\n", ret);
      return ret;
 }
--
Quoted 2 lines

1.8.3.1

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch