Skip to contentSkip to conversation

fix memory leak in fixed btusb_close

PATCH Oliver Neukum 3 participants 5 messages Nov 12, 2009 – Nov 13, 2009 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

If the waker is killed before it can replay outstanding URBs, these URBs won't be freed or will be replayed at the next open. This patch closes the window by explicitely discarding outstanding URBs.

Rafael, could you test this just to make sure? I don't want to screw up the same driver twice.

Regards
Oliver

--

commit 8a3e793888c75bc7a49ff8b0be7ec6bd5438d985

Author: Oliver Neukum <[email protected]>
Date:   Thu Nov 12 16:41:46 2009 +0100

btusb: close race in disconnect leading to a memory leak

if the waker work is cancelled any deferred IO must be discarded in close to free the memory and make sure the data isn't replayed later

drivers/bluetooth/btusb.c +3 -1
index 2fb3802..44bc8bb 100644
@@ -600,11 +600,13 @@ static int btusb_close(struct hci_dev *hdev)
 	btusb_stop_traffic(data);
 	err = usb_autopm_get_interface(data->intf);
 	if (err < 0)
-		return 0;
+		goto failed;
 
 	data->intf->needs_remote_wakeup = 0;
 	usb_autopm_put_interface(data->intf);
 
+failed:
+	usb_scuttle_anchored_urbs(&data->deferred);
 	return 0;
 }
 
#1 lore raw
Quoted 9 lines · Oliver Neukum

If the waker is killed before it can replay outstanding URBs, these URBs won't be freed or will be replayed at the next open. This patch closes the window by explicitely discarding outstanding URBs.

Rafael, could you test this just to make sure? I don't want to screw up the same driver twice.

It doesn't appear to kill the box right away and I have no traces of failure in the logs after several consecutive suspend-resume cycles.

Thanks,
Rafael

maintainer Acked-by
#2 lore raw
In reply to Oliver Neukum

Hi Oliver,

Quoted 6 lines

If the waker is killed before it can replay outstanding URBs, these URBs won't be freed or will be replayed at the next open. This patch closes the window by explicitely discarding outstanding URBs.

Quoted 2 lines

Rafael, could you test this just to make sure? I don't want to screw up the same driver twice.

Feel free to send this directly to Linus for inclusion.

Regards

Marcel

#3 lore raw

Am Freitag, 13. November 2009 04:08:20 schrieb Marcel Holtmann:

Quoted 7 lines

Hi Oliver,

Quoted 5 lines

If the waker is killed before it can replay outstanding URBs, these URBs won't be freed or will be replayed at the next open. This patch closes the window by explicitely discarding outstanding URBs.

Quoted 8 lines
Quoted 1 line
Quoted 2 lines

Rafael, could you test this just to make sure? I don't want to screw up the same driver twice.

Feel free to send this directly to Linus for inclusion.

This late in the RCs?

Regards
Oliver

maintainer
#4 lore raw

Hi Oliver,

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

If the waker is killed before it can replay outstanding URBs, these URBs won't be freed or will be replayed at the next open. This patch closes the window by explicitely discarding outstanding URBs.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Rafael, could you test this just to make sure? I don't want to screw up the same driver twice.

Feel free to send this directly to Linus for inclusion.

This late in the RCs?

he can decide not to take it if chooses, but from my point of view it worth fixing.

Regards

Marcel