[PATCH] conf: Add check to avoid a NULL compare for SysfsPath

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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))) {
    ...
}

Signed-off-by: Cheng Lin <cheng.lin130@xxxxxxxxxx>
---
 src/conf/virnodedeviceobj.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
index c8ad131..2e40de5 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 != NULL) &&
+        (STREQ_NULLABLE(obj->def->sysfs_path, sysfs_path)))
         want = 1;
     virObjectUnlock(obj);
     return want;
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux