* net/bluetooth/rfcomm/tty.c: use-after-free
@ 2007-07-23 1:25 Adrian Bunk
2007-07-23 7:47 ` Marcel Holtmann
0 siblings, 1 reply; 3+ messages in thread
From: Adrian Bunk @ 2007-07-23 1:25 UTC (permalink / raw)
To: Ville Tervo, Marcel Holtmann, maxk; +Cc: bluez-devel, linux-kernel, netdev
Commit 8de0a15483b357d0f0b821330ec84d1660cadc4e added the following
use-after-free in net/bluetooth/rfcomm/tty.c:
<-- snip -->
...
static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
{
...
if (IS_ERR(dev->tty_dev)) {
list_del(&dev->list);
kfree(dev);
return PTR_ERR(dev->tty_dev);
}
...
<-- snip -->
Spotted by the Coverity checker.
cu
Adrian
--
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: net/bluetooth/rfcomm/tty.c: use-after-free
2007-07-23 1:25 net/bluetooth/rfcomm/tty.c: use-after-free Adrian Bunk
@ 2007-07-23 7:47 ` Marcel Holtmann
2007-07-26 7:12 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Marcel Holtmann @ 2007-07-23 7:47 UTC (permalink / raw)
To: Adrian Bunk; +Cc: Ville Tervo, netdev, bluez-devel, maxk, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 637 bytes --]
Hi Adrian,
> Commit 8de0a15483b357d0f0b821330ec84d1660cadc4e added the following
> use-after-free in net/bluetooth/rfcomm/tty.c:
>
> <-- snip -->
>
> ...
> static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
> {
> ...
> if (IS_ERR(dev->tty_dev)) {
> list_del(&dev->list);
> kfree(dev);
> return PTR_ERR(dev->tty_dev);
> }
> ...
>
> <-- snip -->
>
> Spotted by the Coverity checker.
really good catch. I fully overlooked that one. The attached patch
should fix it.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
[-- Attachment #2: patch --]
[-- Type: text/x-patch, Size: 646 bytes --]
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index 23ba61a..22a8320 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -267,7 +267,7 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
out:
write_unlock_bh(&rfcomm_dev_lock);
- if (err) {
+ if (err < 0) {
kfree(dev);
return err;
}
@@ -275,9 +275,10 @@ out:
dev->tty_dev = tty_register_device(rfcomm_tty_driver, dev->id, NULL);
if (IS_ERR(dev->tty_dev)) {
+ err = PTR_ERR(dev->tty_dev);
list_del(&dev->list);
kfree(dev);
- return PTR_ERR(dev->tty_dev);
+ return err;
}
return dev->id;
[-- Attachment #3: Type: text/plain, Size: 315 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
[-- Attachment #4: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: net/bluetooth/rfcomm/tty.c: use-after-free
2007-07-23 7:47 ` Marcel Holtmann
@ 2007-07-26 7:12 ` David Miller
0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2007-07-26 7:12 UTC (permalink / raw)
To: marcel; +Cc: ville.tervo, maxk, netdev, linux-kernel, bunk, bluez-devel
From: Marcel Holtmann <marcel@holtmann.org>
Date: Mon, 23 Jul 2007 09:47:12 +0200
> Hi Adrian,
>
> > Commit 8de0a15483b357d0f0b821330ec84d1660cadc4e added the following
> > use-after-free in net/bluetooth/rfcomm/tty.c:
...
> > Spotted by the Coverity checker.
>
> really good catch. I fully overlooked that one. The attached patch
> should fix it.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Applied, thanks everyone.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-07-26 7:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-23 1:25 net/bluetooth/rfcomm/tty.c: use-after-free Adrian Bunk
2007-07-23 7:47 ` Marcel Holtmann
2007-07-26 7:12 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).