diff mbox

[3/3] drm: simplify master cleanup

Message ID 1430748314-862-3-git-send-email-dh.herrmann@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

David Herrmann May 4, 2015, 2:05 p.m. UTC
In drm_master_destroy() we _free_ the master object. There is no reason to
hold any locks while dropping its static members, nor do we have to reset
it to 0.

Furthermore, kfree() already does NULL checks, so call it directly on
master->unique and drop the redundant reset-code.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 drivers/gpu/drm/drm_drv.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Comments

Chris Wilson May 4, 2015, 2:47 p.m. UTC | #1
On Mon, May 04, 2015 at 04:05:14PM +0200, David Herrmann wrote:
> In drm_master_destroy() we _free_ the master object. There is no reason to
> hold any locks while dropping its static members, nor do we have to reset
> it to 0.
> 
> Furthermore, kfree() already does NULL checks, so call it directly on
> master->unique and drop the redundant reset-code.
> 
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
Daniel Vetter May 5, 2015, 7:47 a.m. UTC | #2
On Mon, May 04, 2015 at 03:47:13PM +0100, Chris Wilson wrote:
> On Mon, May 04, 2015 at 04:05:14PM +0200, David Herrmann wrote:
> > In drm_master_destroy() we _free_ the master object. There is no reason to
> > hold any locks while dropping its static members, nor do we have to reset
> > it to 0.
> > 
> > Furthermore, kfree() already does NULL checks, so call it directly on
> > master->unique and drop the redundant reset-code.
> > 
> > Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

Both kernel and igt patches applied, thanks.
-Daniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 88b594c..3b3c4f5 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -132,15 +132,10 @@  static void drm_master_destroy(struct kref *kref)
 			r_list = NULL;
 		}
 	}
-
-	if (master->unique) {
-		kfree(master->unique);
-		master->unique = NULL;
-		master->unique_len = 0;
-	}
 	mutex_unlock(&dev->struct_mutex);
 
 	idr_destroy(&master->magic_map);
+	kfree(master->unique);
 	kfree(master);
 }