mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
conf: Add check to avoid a NULL compare for SysfsPath
If the two sysfs_path are both NULL, there may be an incorrect object returned for virNodeDeviceObjListFindBySysfsPath(). This check exists in old interface virNodeDeviceFindBySysfsPath(). e.g. virNodeDeviceFindBySysfsPath(virNodeDeviceObjListPtr devs, const char *sysfs_path) { ... if ((devs->objs[i]->def->sysfs_path != NULL) && (STREQ(devs->objs[i]->def->sysfs_path, sysfs_path))) { ... } Reviewed-by: Cole Robinson <crobinso@redhat.com> Signed-off-by: Cheng Lin <cheng.lin130@zte.com.cn>
This commit is contained in:
parent
ca768886d8
commit
d2edbec2bf
@ -207,7 +207,8 @@ virNodeDeviceObjListFindBySysfsPathCallback(const void *payload,
|
||||
int want = 0;
|
||||
|
||||
virObjectLock(obj);
|
||||
if (STREQ_NULLABLE(obj->def->sysfs_path, sysfs_path))
|
||||
if (obj->def->sysfs_path &&
|
||||
STREQ_NULLABLE(obj->def->sysfs_path, sysfs_path))
|
||||
want = 1;
|
||||
virObjectUnlock(obj);
|
||||
return want;
|
||||
|
Loading…
Reference in New Issue
Block a user