From 92a80db13fc4fe2ce789d087261dcfefffbb4f1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Hundeb=C3=B8ll?= Date: Fri, 24 Aug 2018 13:33:30 +0200 Subject: [PATCH] udevng: fix removal of serial devices Since the merge of udev.c into udevng.c all cleanup function must handle both usb devices and serial devices. Add this distinction to check_remove(), so that is doesn't try to iterate the .serial member as if it were a .devices list. --- plugins/udevng.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/plugins/udevng.c b/plugins/udevng.c index 4b565070..71a70f0b 100644 --- a/plugins/udevng.c +++ b/plugins/udevng.c @@ -1380,11 +1380,19 @@ static gboolean check_remove(gpointer key, gpointer value, gpointer user_data) const char *devpath = user_data; GSList *list; - for (list = modem->devices; list; list = list->next) { - struct device_info *info = list->data; + switch (modem->type) { + case MODEM_TYPE_USB: + for (list = modem->devices; list; list = list->next) { + struct device_info *info = list->data; - if (g_strcmp0(info->devpath, devpath) == 0) + if (g_strcmp0(info->devpath, devpath) == 0) + return TRUE; + } + break; + case MODEM_TYPE_SERIAL: + if (g_strcmp0(modem->serial->devpath, devpath) == 0) return TRUE; + break; } return FALSE;