public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [Patch] Zarlink zl10036 DVB-S: Fix mem leak in zl10036_attach
@ 2011-02-06 20:33 Jesper Juhl
  2011-02-17 19:54 ` Matthias Schwarzott
  0 siblings, 1 reply; 5+ messages in thread
From: Jesper Juhl @ 2011-02-06 20:33 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-media, Dan Carpenter, Tejun Heo, Matthias Schwarzott,
	Mauro Carvalho Chehab

If the memory allocation to 'state' succeeds but we jump to the 'error' 
label before 'state' is assigned to fe->tuner_priv, then the call to 
'zl10036_release(fe)' at the 'error:' label will not free 'state', but 
only what was previously assigned to 'tuner_priv', thus leaking the memory 
allocated to 'state'.
There are may ways to fix this, including assigning the allocated memory 
directly to 'fe->tuner_priv', but I did not go for that since the 
additional pointer derefs are more expensive than the local variable, so I 
just added a 'kfree(state)' call. I guess the call to 'zl10036_release' 
might not even be needed in this case, but I wasn't sure, so I left it in.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 zl10036.c |    1 +
 1 file changed, 1 insertion(+)

 compile tested only.

diff --git a/drivers/media/dvb/frontends/zl10036.c b/drivers/media/dvb/frontends/zl10036.c
index 4627f49..b4fb8e8 100644
--- a/drivers/media/dvb/frontends/zl10036.c
+++ b/drivers/media/dvb/frontends/zl10036.c
@@ -508,6 +508,7 @@ struct dvb_frontend *zl10036_attach(struct dvb_frontend *fe,
 
 error:
 	zl10036_release(fe);
+	kfree(state);
 	return NULL;
 }
 EXPORT_SYMBOL(zl10036_attach);


-- 
Jesper Juhl <jj@chaosbits.net>            http://www.chaosbits.net/
Plain text mails only, please.
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-03-21 20:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-06 20:33 [Patch] Zarlink zl10036 DVB-S: Fix mem leak in zl10036_attach Jesper Juhl
2011-02-17 19:54 ` Matthias Schwarzott
2011-02-17 20:33   ` Jesper Juhl
2011-02-17 20:45     ` Matthias Schwarzott
2011-03-21 20:36       ` Jesper Juhl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox