Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Unified Diff: device/usb/usb_device_handle_impl.cc

Issue 1126203008: Avoid a race between libusb_submit_transfer and libusb_free_transfer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/usb/usb_device_handle_impl.cc
diff --git a/device/usb/usb_device_handle_impl.cc b/device/usb/usb_device_handle_impl.cc
index 921af4f2225f37fc8bda9fdbaf38e5004281745a..bd53ada53288f2645b5207de329d9c69c8bfded7 100644
--- a/device/usb/usb_device_handle_impl.cc
+++ b/device/usb/usb_device_handle_impl.cc
@@ -485,7 +485,7 @@ void UsbDeviceHandleImpl::Transfer::TransferComplete(UsbTransferStatus status,
task_runner_->PostTask(
FROM_HERE,
base::Bind(&UsbDeviceHandleImpl::TransferComplete, device_handle_,
- base::Owned(this),
+ base::Unretained(this),
base::Bind(callback_, status, buffer_, bytes_transferred)));
}
@@ -970,6 +970,10 @@ void UsbDeviceHandleImpl::TransferComplete(Transfer* transfer,
} else {
transfer->callback_task_runner()->PostTask(FROM_HERE, callback);
}
+
+ // libusb_free_transfer races with libusb_submit_transfer and only work-
+ // around is to make sure to call them on the same thread.
+ blocking_task_runner_->DeleteSoon(FROM_HERE, transfer);
}
void UsbDeviceHandleImpl::InternalClose() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698