Skip to content

Commit

Permalink
[M-67] Add check for failure to initialize UdevWatcher
Browse files Browse the repository at this point in the history
When udev fails to initialize UdevWatcher::StartWatching will return
nullptr. This checks for that case (preventing a crash) and leaves the
UsbService in a good state even when it is incapable of enumerating
devices.

Bug: 840243
Change-Id: I3d251daa79178e1ea7e924e2fe9afaf7ff3d16a7
Reviewed-on: https://chromium-review.googlesource.com/1048033
Reviewed-by: Jun Cai <juncai@chromium.org>
Commit-Queue: Reilly Grant <reillyg@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#556537}(cherry picked from commit 3d72841)
Reviewed-on: https://chromium-review.googlesource.com/1048365
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/branch-heads/3396@{#505}
Cr-Branched-From: 9ef2aa8-refs/heads/master@{#550428}
  • Loading branch information
reillyeon committed May 7, 2018
1 parent 402a4ba commit f6dfe7e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion device/usb/usb_service_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,12 @@ void UsbServiceLinux::FileThreadHelper::Start() {
DCHECK(sequence_checker_.CalledOnValidSequence());
base::AssertBlockingAllowed();

// Initializing udev for device enumeration and monitoring may fail. In that
// case this service will continue to exist but no devices will be found.
watcher_ = UdevWatcher::StartWatching(this);
watcher_->EnumerateExistingDevices();
if (watcher_)
watcher_->EnumerateExistingDevices();

task_runner_->PostTask(
FROM_HERE, base::BindOnce(&UsbServiceLinux::HelperStarted, service_));
}
Expand Down

0 comments on commit f6dfe7e

Please sign in to comment.