From d5c2d1efff92b2b992f10b29bd459a4b07875025 Mon Sep 17 00:00:00 2001 From: Steven Galgano Date: Mon, 14 Oct 2024 15:16:36 -0400 Subject: [PATCH] Avoid null pointer dereference when using shared rootfs. 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 --- src/lxc/conf.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 4b46d24bf..6a14c6036 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -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) -- 2.47.2