提交 d2edbec2 编写于 作者: C Cheng Lin 提交者: Cole Robinson

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: NCole Robinson <crobinso@redhat.com>
Signed-off-by: NCheng Lin <cheng.lin130@zte.com.cn>
上级 ca768886
...@@ -207,7 +207,8 @@ virNodeDeviceObjListFindBySysfsPathCallback(const void *payload, ...@@ -207,7 +207,8 @@ virNodeDeviceObjListFindBySysfsPathCallback(const void *payload,
int want = 0; int want = 0;
virObjectLock(obj); 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; want = 1;
virObjectUnlock(obj); virObjectUnlock(obj);
return want; return want;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册