sd-device: fix segfault when error occurs in device_new_from_{nulstr,strv}()
As devpath may not be set yet. When debug logging is enabled, log_device_*() calls sd_device_get_sysname(). So, we should not assume that devpath is always set. Fixes #11258.
This commit is contained in:
parent
04ca4d191b
commit
18fee12a2d
|
@ -1002,6 +1002,9 @@ static int device_set_sysname(sd_device *device) {
|
|||
const char *pos;
|
||||
size_t len = 0;
|
||||
|
||||
if (!device->devpath)
|
||||
return -EINVAL;
|
||||
|
||||
pos = strrchr(device->devpath, '/');
|
||||
if (!pos)
|
||||
return -EINVAL;
|
||||
|
|
Loading…
Reference in a new issue