From: Cheng Lin Date: Fri, 18 Jan 2019 07:49:37 +0000 (+0800) Subject: conf: Add check to avoid a NULL compare for SysfsPath X-Git-Tag: v5.1.0-rc1~385 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2edbec2bf281025f27646d61d3b7ec3ed662f5d;p=thirdparty%2Flibvirt.git 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 Signed-off-by: Cheng Lin --- diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c index c8ad1314b5..6df2985561 100644 --- a/src/conf/virnodedeviceobj.c +++ b/src/conf/virnodedeviceobj.c @@ -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;