diff options
author | Michael Krufky <mkrufky@linuxtv.org> | 2007-06-04 15:00:45 -0400 |
---|---|---|
committer | Michael Krufky <mkrufky@linuxtv.org> | 2007-06-04 15:00:45 -0400 |
commit | 86d97675ab308eedbdf3547b6d52dc716f778991 (patch) | |
tree | c326559b44e5bf3363941b2273b4001d875a9418 /linux/drivers/media/video/tuner-core.c | |
parent | 9ee5949a70d76f5d85edf7d5571af93917eeff0a (diff) | |
download | mediapointer-dvb-s2-86d97675ab308eedbdf3547b6d52dc716f778991.tar.gz mediapointer-dvb-s2-86d97675ab308eedbdf3547b6d52dc716f778991.tar.bz2 |
tuner: clean up kfree() after release
From: Michael Krufky <mkrufky@linuxtv.org>
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 <mkrufky@linuxtv.org>
Diffstat (limited to 'linux/drivers/media/video/tuner-core.c')
-rw-r--r-- | linux/drivers/media/video/tuner-core.c | 12 |
1 files changed, 8 insertions, 4 deletions
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; } |