[PATCH] base-manager: avoid events of USB interface from removing MMDevice

Aleksander Morgado aleksander at aleksander.es
Tue Aug 22 12:01:05 UTC 2017


On 22/08/17 03:42, Ben Chan wrote:
> 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.
> ---
> Given that we'll eventually remove the special handling code, this is probably
> the least intrusive way to work around the issue in the meantime.
> 

Let's merge this one and keep the discussion open of whether we should completely remove that logic. I'll try to run tests with all my tty based modems in the next weeks.

I did a minor reorder in the patch and merged to git master and backported to mm-1-6 and mm-1-4.

> 
>  src/mm-base-manager.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/src/mm-base-manager.c b/src/mm-base-manager.c
> index 48e2f25d..f5ccb1c5 100644
> --- a/src/mm-base-manager.c
> +++ b/src/mm-base-manager.c
> @@ -248,6 +248,18 @@ device_removed (MMBaseManager  *self,
>       * device has been removed.  That way, if the device is reinserted later, we'll go through
>       * the process of exporting it.
>       */
> +#if defined WITH_UDEV
> +    /* 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 (mm_kernel_device_get_property (kernel_device, "DEVTYPE"), "usb_device") != 0)
> +        return;
> +#endif
>      device = find_device_by_kernel_device (self, kernel_device);
>      if (device) {
>          mm_dbg ("Removing device '%s'", mm_device_get_uid (device));
> 


-- 
Aleksander
https://aleksander.es


More information about the ModemManager-devel mailing list