[PATCH] staging; lirc, zilog: put_ir_rx may free 'rx' which can lead to double free

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx>
---
 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@xxxxxxxxxxxxx>       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
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux