linux: up-enumerator-udev: Prevent reading the sysfs path from a non-GUdevDevice object

A non-GUdevDevice object may be included in the sibling device list,
since the udev information was created slowly. This object triggers
errors when upower tries to get udev information. Therefore,
get_latest_udev_device() returns NULL, when it receives a non-GUdevDevice
object.

The error messages are shown as follows:
(upowerd:2026931): GUdev-CRITICAL **: 10:38:29.775: g_udev_device_get_sysfs_path: assertion 'G_UDEV_IS_DEVICE (device)' failed

(upowerd:2026931): GUdev-CRITICAL **: 10:38:29.775: g_udev_client_query_by_sysfs_path: assertion 'sysfs_path != NULL' failed
This commit is contained in:
Kate Hsuan 2025-05-02 14:16:31 +08:00
parent 7ae19b529f
commit 38317a118d

View file

@ -178,6 +178,12 @@ get_latest_udev_device (UpEnumeratorUdev *self,
{
const char *sysfs_path;
/* return NULL when receiving a non-GUdevDevice object */
if (!G_UDEV_IS_DEVICE (obj)) {
g_debug ("Receiving a non-udev object.");
return NULL;
}
sysfs_path = g_udev_device_get_sysfs_path (G_UDEV_DEVICE (obj));
return g_udev_client_query_by_sysfs_path (self->udev, sysfs_path);
}