mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-09 09:31:16 +00:00
udev-device: Fix critical warning if the device has no parent
This commit is contained in:
parent
5502cd5689
commit
fc4fbfc98f
@ -91,6 +91,7 @@ fu_udev_device_probe (FuDevice *device, GError **error)
|
|||||||
FuUdevDevicePrivate *priv = GET_PRIVATE (self);
|
FuUdevDevicePrivate *priv = GET_PRIVATE (self);
|
||||||
const gchar *tmp;
|
const gchar *tmp;
|
||||||
g_autofree gchar *subsystem = NULL;
|
g_autofree gchar *subsystem = NULL;
|
||||||
|
g_autoptr(GUdevDevice) udev_parent = NULL;
|
||||||
|
|
||||||
/* set ven:dev:rev */
|
/* set ven:dev:rev */
|
||||||
priv->vendor = fu_udev_device_get_sysfs_attr_as_uint64 (priv->udev_device, "vendor");
|
priv->vendor = fu_udev_device_get_sysfs_attr_as_uint64 (priv->udev_device, "vendor");
|
||||||
@ -98,17 +99,18 @@ fu_udev_device_probe (FuDevice *device, GError **error)
|
|||||||
priv->revision = fu_udev_device_get_sysfs_attr_as_uint64 (priv->udev_device, "revision");
|
priv->revision = fu_udev_device_get_sysfs_attr_as_uint64 (priv->udev_device, "revision");
|
||||||
|
|
||||||
/* fallback to the parent */
|
/* fallback to the parent */
|
||||||
if (priv->vendor == 0x0 && priv->model == 0x0 && priv->revision == 0x0) {
|
udev_parent = g_udev_device_get_parent (priv->udev_device);
|
||||||
g_autoptr(GUdevDevice) parent = g_udev_device_get_parent (priv->udev_device);
|
if (udev_parent != NULL &&
|
||||||
priv->vendor = fu_udev_device_get_sysfs_attr_as_uint64 (parent, "vendor");
|
priv->vendor == 0x0 && priv->model == 0x0 && priv->revision == 0x0) {
|
||||||
priv->model = fu_udev_device_get_sysfs_attr_as_uint64 (parent, "device");
|
priv->vendor = fu_udev_device_get_sysfs_attr_as_uint64 (udev_parent, "vendor");
|
||||||
priv->revision = fu_udev_device_get_sysfs_attr_as_uint64 (parent, "revision");
|
priv->model = fu_udev_device_get_sysfs_attr_as_uint64 (udev_parent, "device");
|
||||||
|
priv->revision = fu_udev_device_get_sysfs_attr_as_uint64 (udev_parent, "revision");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* hidraw helpfully encodes the information in a different place */
|
/* hidraw helpfully encodes the information in a different place */
|
||||||
if (priv->vendor == 0x0 && priv->model == 0x0 && priv->revision == 0x0 &&
|
if (udev_parent != NULL &&
|
||||||
|
priv->vendor == 0x0 && priv->model == 0x0 && priv->revision == 0x0 &&
|
||||||
g_strcmp0 (g_udev_device_get_subsystem (priv->udev_device), "hidraw") == 0) {
|
g_strcmp0 (g_udev_device_get_subsystem (priv->udev_device), "hidraw") == 0) {
|
||||||
g_autoptr(GUdevDevice) udev_parent = g_udev_device_get_parent (priv->udev_device);
|
|
||||||
tmp = g_udev_device_get_property (udev_parent, "HID_ID");
|
tmp = g_udev_device_get_property (udev_parent, "HID_ID");
|
||||||
if (tmp != NULL && strlen (tmp) == 22) {
|
if (tmp != NULL && strlen (tmp) == 22) {
|
||||||
priv->vendor = fu_udev_device_read_uint16 (tmp + 10);
|
priv->vendor = fu_udev_device_read_uint16 (tmp + 10);
|
||||||
|
Loading…
Reference in New Issue
Block a user