From 86d97675ab308eedbdf3547b6d52dc716f778991 Mon Sep 17 00:00:00 2001 From: Michael Krufky Date: Mon, 4 Jun 2007 15:00:45 -0400 Subject: tuner: clean up kfree() after release From: Michael Krufky Although it is safe to kfree(NULL), We only need to kfree(priv) if the release callback is undefined. As it stands now, there is some redundancy in the operation of releasing the priv data structures. This patch will call kfree(priv) and set priv to NULL, if the release callback isnt defined. Otherwise, let the release callback handle this itself. Thanks to Mauro Carvalho Chehab for suggesting this. Signed-off-by: Michael Krufky --- linux/drivers/media/video/tuner-core.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'linux/drivers/media') diff --git a/linux/drivers/media/video/tuner-core.c b/linux/drivers/media/video/tuner-core.c index d2c946e2a..e00c59873 100644 --- a/linux/drivers/media/video/tuner-core.c +++ b/linux/drivers/media/video/tuner-core.c @@ -207,8 +207,10 @@ static void set_type(struct i2c_client *c, unsigned int type, /* discard private data, in case set_type() was previously called */ if (t->release) t->release(c); - kfree(t->priv); - t->priv = NULL; + else { + kfree(t->priv); + t->priv = NULL; + } switch (t->type) { case TUNER_MT2032: @@ -623,10 +625,12 @@ MOD_DEC_USE_COUNT; #endif if (t->release) t->release(client); - kfree(t->priv); + else { + kfree(t->priv); #if 0 - t->priv = NULL; + t->priv = NULL; #endif + } kfree(t); return 0; } -- cgit v1.2.3