On Fri, 29 Jul 2011, Dan Carpenter wrote:

> On Thu, Jul 28, 2011 at 11:49:51PM +0200, Jesper Juhl wrote:
> > 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.
> 
> It would be better to just remove the first call to put_ir_rx().
> 

Taking a second look... Yes, you are right, that would be just fine and a 
lot simpler. Thanks for reviewing.

Here's an updated patch.


From: Jesper Juhl <[email protected]>
Subject: [PATCH] staging; lirc, zilog: put_ir_rx may free 'rx' which can lead 
to double free

If the call to 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, simply remove the first call to put_ir_rx().

Signed-off-by: Jesper Juhl <[email protected]>
---
 drivers/staging/lirc/lirc_zilog.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/lirc/lirc_zilog.c 
b/drivers/staging/lirc/lirc_zilog.c
index 0302d82..6be6f67 100644
--- a/drivers/staging/lirc/lirc_zilog.c
+++ b/drivers/staging/lirc/lirc_zilog.c
@@ -1577,7 +1577,6 @@ 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);
                        ir->l.features &= ~LIRC_CAN_REC_LIRCCODE;
                        goto out_put_xx;
                }
-- 
1.7.6

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

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel

Reply via email to