lkml.org 
[lkml]   [2011]   [Jul]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] staging; lirc, zilog: put_ir_rx may free 'rx' which can lead to double free
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.



\
 
 \ /
  Last update: 2011-07-28 23:53    [W:0.099 / U:0.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site