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>
/* 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:
if (t->release)
t->release(client);
- kfree(t->priv);
+ else {
+ kfree(t->priv);
+ }
kfree(t);
return 0;
}