For evemu devices, the subsystem is only input until we arrive at the NULL
parent. If that's the case, don't try to get the subsystem from a NULL
pointer but return a unknown subsystem instead.

Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
---
 libwacom/libwacom.c |   15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/libwacom/libwacom.c b/libwacom/libwacom.c
index 811948a..103f942 100644
--- a/libwacom/libwacom.c
+++ b/libwacom/libwacom.c
@@ -60,17 +60,20 @@ get_bus (GUdevDevice *device)
        while (parent && g_strcmp0 (subsystem, "input") == 0) {
                GUdevDevice *old_parent = parent;
                parent = g_udev_device_get_parent (old_parent);
-               subsystem = g_udev_device_get_subsystem (parent);
+               if (parent)
+                       subsystem = g_udev_device_get_subsystem (parent);
                g_object_unref (old_parent);
        }
 
-       if (g_strcmp0 (subsystem, "tty") == 0 || g_strcmp0 (subsystem, "serio") 
== 0)
-               bus_str = g_strdup ("serial");
-       else
-               bus_str = g_strdup (subsystem);
+       if (parent) {
+               if (g_strcmp0 (subsystem, "tty") == 0 || g_strcmp0 (subsystem, 
"serio") == 0)
+                       bus_str = g_strdup ("serial");
+               else
+                       bus_str = g_strdup (subsystem);
 
-       if (parent)
                g_object_unref (parent);
+       } else
+               bus_str = strdup("unknown");
 
        return bus_str;
 }
-- 
1.7.10.1


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to