]> xenbits.xensource.com Git - libvirt.git/commitdiff
lxc: fix lxcContainerMountAllFS() DEREF_BEFORE_CHECK
authorDmitry Frolov <frolov@swemel.ru>
Thu, 7 Sep 2023 09:04:57 +0000 (12:04 +0300)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 20 Oct 2023 10:17:56 +0000 (12:17 +0200)
vmDef->fss[i]->src->path may be NULL,
so check is needed before passing it to VIR_DEBUG.
Also removed checking vmDef->fss[i]->src for NULL, since it may not be NULL.

Fixes: 57487085dc ("lxc: don't try to reference NULL when mounting filesystems")
Signed-off-by: Dmitry Frolov <frolov@swemel.ru>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/lxc/lxc_container.c

index fe1e190fa9afacb512434f6328cc5dafc70467fc..35a882171b5daa9f78a5caed911d86f735e8c521 100644 (file)
@@ -1467,12 +1467,13 @@ static int lxcContainerMountAllFS(virDomainDef *vmDef,
         if (STREQ(vmDef->fss[i]->dst, "/"))
             continue;
 
-        VIR_DEBUG("Mounting '%s' -> '%s'", vmDef->fss[i]->src->path, vmDef->fss[i]->dst);
+        VIR_DEBUG("Mounting '%s' -> '%s'", NULLSTR(vmDef->fss[i]->src->path),
+                  vmDef->fss[i]->dst);
 
         if (lxcContainerResolveSymlinks(vmDef->fss[i], false) < 0)
             return -1;
 
-        if (!(vmDef->fss[i]->src && vmDef->fss[i]->src->path &&
+        if (!(vmDef->fss[i]->src->path &&
               STRPREFIX(vmDef->fss[i]->src->path, vmDef->fss[i]->dst)) &&
             lxcContainerUnmountSubtree(vmDef->fss[i]->dst, false) < 0)
             return -1;