diff options
author | Ben Chan <benchan@chromium.org> | 2017-08-21 18:42:25 -0700 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2017-08-22 13:54:51 +0200 |
commit | a22866a424aa56fac89ac385caf25f4b696b9014 (patch) | |
tree | 5c101566dbb220fb2d6cfab79c4b423994df7c65 | |
parent | 590ea8dcd6d4ed10c79818480126e6d20a394a14 (diff) | |
download | ModemManager-a22866a424aa56fac89ac385caf25f4b696b9014.tar.gz |
base-manager: avoid events of USB interface from removing MMDevice
When a USB modem is switching its USB configuration, udev may deliver
the remove events of USB interfaces associated with the old USB
configuration and the add events of USB interfaces associated with the new USB
configuration in an interleaved fashion. An interleaved remove event of USB
interface could trigger the special case handling code in
mm-base-manager.c:device_removed() and incorrectly remove a MMDevice under
probing.
See https://lists.freedesktop.org/archives/modemmanager-devel/2017-August/005626.html
for more details.
This patch adds a check to ensure that only remove events of USB
device (i.e. not interface) can trigger the special handling code.
(cherry picked from commit 76c1a1119cdb08c710b5f8df35c31883a466a64a)
-rw-r--r-- | src/mm-base-manager.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/mm-base-manager.c b/src/mm-base-manager.c index 827b587ab..df5e8fdfa 100644 --- a/src/mm-base-manager.c +++ b/src/mm-base-manager.c @@ -280,6 +280,17 @@ device_removed (MMBaseManager *self, return; } + /* When a USB modem is switching its USB configuration, udev may deliver + * the remove events of USB interfaces associated with the old USB + * configuration and the add events of USB interfaces associated with the + * new USB configuration in an interleaved fashion. As we don't want a + * remove event of an USB interface trigger the removal of a MMDevice for + * the special case being handled here, we ignore any remove event with + * DEVTYPE != usb_device. + */ + if (g_strcmp0 (g_udev_device_get_property (udev_device, "DEVTYPE"), "usb_device") != 0) + return; + /* This case is designed to handle the case where, at least with kernel 2.6.31, unplugging * an in-use ttyACMx device results in udev generating remove events for the usb, but the * ttyACMx device (subsystem tty) is not removed, since it was in-use. So if we have not |