* [PATCH] [media] Staging: media/lirc: don't call put_ir_rx on rx twice
@ 2017-02-17 16:17 Colin King
2017-02-17 22:12 ` Dan Carpenter
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2017-02-17 16:17 UTC (permalink / raw)
To: Jarod Wilson, Mauro Carvalho Chehab, Greg Kroah-Hartman,
Mihaela Muraru, RitwikGopi, linux-media, devel
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
There is an exit path where rx is kfree'd on put_ir_rx and then
a jump to label out_put_xx will again kfree it with another
call to put_ir_rx. Fix this by adding a new label that avoids
this 2nd call to put_ir_rx for this specific case.
Detected with CoverityScan, CID#145119 ("Use after free")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/staging/media/lirc/lirc_zilog.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/media/lirc/lirc_zilog.c b/drivers/staging/media/lirc/lirc_zilog.c
index 34aac3e..5dd1e62 100644
--- a/drivers/staging/media/lirc/lirc_zilog.c
+++ b/drivers/staging/media/lirc/lirc_zilog.c
@@ -1597,7 +1597,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
i2c_set_clientdata(client, NULL);
put_ir_rx(rx, true);
ir->l.features &= ~LIRC_CAN_REC_LIRCCODE;
- goto out_put_xx;
+ goto out_put_tx;
}
/* Proceed only if the Tx client is also ready */
@@ -1637,6 +1637,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
out_put_xx:
if (rx != NULL)
put_ir_rx(rx, true);
+out_put_tx:
if (tx != NULL)
put_ir_tx(tx, true);
out_put_ir:
--
2.10.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] [media] Staging: media/lirc: don't call put_ir_rx on rx twice
2017-02-17 16:17 [PATCH] [media] Staging: media/lirc: don't call put_ir_rx on rx twice Colin King
@ 2017-02-17 22:12 ` Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2017-02-17 22:12 UTC (permalink / raw)
To: Colin King
Cc: Jarod Wilson, Mauro Carvalho Chehab, Greg Kroah-Hartman,
Mihaela Muraru, RitwikGopi, linux-media, devel, kernel-janitors,
linux-kernel
This one is a false positive. The original code is correct.
I was looking through my mail boxes to see the history of this and why
it hadn't been fixed earlier. Someone tried to fix it in 2011:
https://www.spinics.net/lists/linux-driver-devel/msg17403.html
Then I complained about it again in 2014 when I was looking at a
different bug in that same function. Now you're the third person to
think this code is suspicious.
I think part of the problem is that get_ir_rx(ir) is hidden as a
function parameter instead of on its own line. But really even that
wouldn't totally fix the issue.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-02-17 22:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-17 16:17 [PATCH] [media] Staging: media/lirc: don't call put_ir_rx on rx twice Colin King
2017-02-17 22:12 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox