Skip to content

Commit

Permalink
V4L/DVB (5743): Tuner: clean up kfree() after release
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
  • Loading branch information
Michael Krufky authored and Mauro Carvalho Chehab committed Jul 18, 2007
1 parent 024cf53 commit 052c50d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions drivers/media/video/tuner-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,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:
Expand Down Expand Up @@ -566,7 +568,9 @@ static int tuner_detach(struct i2c_client *client)

if (t->release)
t->release(client);
kfree(t->priv);
else {
kfree(t->priv);
}
kfree(t);
return 0;
}
Expand Down

0 comments on commit 052c50d

Please sign in to comment.