sixaxis: Fix crash caused by return of udev_device_get_property_value
authorMiao-chen Chou <mcchou@chromium.org>
Wed, 16 Sep 2020 22:34:53 +0000 (15:34 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:32 +0000 (19:08 +0530)
This adds a NULL check before calling sscanf().

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
plugins/sixaxis.c

index 3e14332..bed50d5 100755 (executable)
@@ -410,7 +410,7 @@ get_pairing_type_for_device(struct udev_device *udevice, uint16_t *bus,
 
        hid_id = udev_device_get_property_value(hid_parent, "HID_ID");
 
-       if (sscanf(hid_id, "%hx:%hx:%hx", bus, &vid, &pid) != 3)
+       if (!hid_id || sscanf(hid_id, "%hx:%hx:%hx", bus, &vid, &pid) != 3)
                return NULL;
 
        cp = get_pairing(vid, pid);