All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging; lirc, zilog: put_ir_rx may free 'rx' which can lead to double free
@ 2011-07-28 21:49 Jesper Juhl
  2011-07-29  6:08 ` Dan Carpenter
  0 siblings, 1 reply; 7+ messages in thread
From: Jesper Juhl @ 2011-07-28 21:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jarod Wilson, Greg Kroah-Hartman, Mauro Carvalho Chehab,
	Andy Walls, devel, Gerd Knorr, Michal Kochanowicz,
	Christoph Bartelmus, Ulrich Mueller, Stefan Jahn, Jerome Brock,
	Thomas Reitmayr, Mark Weaver, Jarod Wilson

If calling put_ir_rx(rx, true); in
drivers/staging/lirc/lirc_zilog.c::ir_probe() returns true (1) then it
means that it has freed it's first argument. Subsequently jumping to
'out_put_xx' will cause us to call put_ir_rx() once more since 'rx' is
not zero - leading to a double free.
To fix this, test the return value of 'put_ir_rx()' and if it is true
(1), zero 'rx' so that we won't do it again.

I'm not familiar with this code, so this may not be the best fix, and
I also don't have the hardware to test it properly, so this patch is
compile tested only and someone who knows this code should probably
ACK it before it's merged.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 drivers/staging/lirc/lirc_zilog.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/lirc/lirc_zilog.c b/drivers/staging/lirc/lirc_zilog.c
index 0302d82..51ded22 100644
--- a/drivers/staging/lirc/lirc_zilog.c
+++ b/drivers/staging/lirc/lirc_zilog.c
@@ -1577,7 +1577,8 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
 			put_ir_device(ir, true);
 			/* Failure exit, so put back rx ref from i2c_client */
 			i2c_set_clientdata(client, NULL);
-			put_ir_rx(rx, true);
+			if (put_ir_rx(rx, true))
+				rx = NULL;
 			ir->l.features &= ~LIRC_CAN_REC_LIRCCODE;
 			goto out_put_xx;
 		}
-- 
1.7.6


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


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

end of thread, other threads:[~2011-07-31 12:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-28 21:49 [PATCH] staging; lirc, zilog: put_ir_rx may free 'rx' which can lead to double free Jesper Juhl
2011-07-29  6:08 ` Dan Carpenter
2011-07-29  9:14   ` Jesper Juhl
2011-07-29 10:03   ` Andy Walls
2011-07-29 10:26     ` Jesper Juhl
2011-07-31 12:42   ` Andy Walls
2011-07-31 12:49   ` Andy Walls

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.