]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Avoid null pointer dereference when using shared rootfs. 4488/head
authorSteven Galgano <sgalgano@adjacentlink.com>
Mon, 14 Oct 2024 19:16:36 +0000 (15:16 -0400)
committerSteven Galgano <sgalgano@adjacentlink.com>
Mon, 14 Oct 2024 19:30:57 +0000 (15:30 -0400)
rootfs->storage not set by lxc_storage_prepare when using a shared
rootfs.

Fixes: https://github.com/lxc/lxc/issues/4476
Signed-off-by: Steven Galgano <sgalgano@adjacentlink.com>
src/lxc/conf.c

index 4b46d24bfe5689a6f423d3691ade1642114983fd..6a14c60360094b86d57ed2f7341e33fd5c52c415 100644 (file)
@@ -341,6 +341,10 @@ int lxc_rootfs_init(struct lxc_conf *conf, bool userns)
        ret = lxc_storage_prepare(conf);
        if (ret)
                return syserror_set(-EINVAL, "Failed to prepare rootfs storage");
+
+       if (!rootfs->storage)
+               return log_trace(0, "Not pinning because container does not have storage");
+
        type = rootfs->storage->type;
 
        if (!type)