mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +00:00
udev_device_get_devpath might return NULL
Fix crash on strdup in that case.
This commit is contained in:
parent
a4e09c1ed8
commit
1f60411686
@ -947,8 +947,14 @@ static int udevProcessStorage(struct udev_device *device,
|
|||||||
{
|
{
|
||||||
union _virNodeDevCapData *data = &def->caps->data;
|
union _virNodeDevCapData *data = &def->caps->data;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
const char* devnode;
|
||||||
|
|
||||||
data->storage.block = strdup(udev_device_get_devnode(device));
|
devnode = udev_device_get_devnode(device);
|
||||||
|
if(!devnode) {
|
||||||
|
VIR_DEBUG("No devnode for '%s'\n", udev_device_get_devpath(device));
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
data->storage.block = strdup(devnode);
|
||||||
if (udevGetStringProperty(device,
|
if (udevGetStringProperty(device,
|
||||||
"DEVNAME",
|
"DEVNAME",
|
||||||
&data->storage.block) == PROPERTY_ERROR) {
|
&data->storage.block) == PROPERTY_ERROR) {
|
||||||
|
Loading…
Reference in New Issue
Block a user