kernel-device: use device sysfs if physdev sysfs isn't available

find_device_by_physdev_uid() expects a non-NULL UID of the physical
device. However, mm_kernel_device_get_physdev_uid() could potentially
return NULL on MMKernelDeviceUdev if find_physical_gudevdevice() in
mm-kernel-device-udev.c fails to find the physical device. When a NULL
physical device UID is passed to find_device_by_physdev_uid() and used
in g_hash_table_lookup(), it leads to a crash in g_str_hash(), which is
a bit obscure.

This patch updates kernel_device_get_physdev_uid() in
mm-kernel-device-udev.c to fall back to use the device sysfs if the
physical device sysfs isn't available, which is similar to how
kernel_device_get_physdev_uid() mm-kernel-device-generic.c is
implemented.

(cherry picked from commit f0cda2093078d630ca164b3872f742609e091a20)

BUG=chromium:697724
TEST=`FEATURES=test emerge-$BOARD modemmanager-next`

Change-Id: Ia849b2713ee4b37a07f62836def5979f7438a621
Reviewed-on: https://chromium-review.googlesource.com/461249
Reviewed-by: Ben Chan <benchan@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
1 file changed