shiftfs: Handle multiple frees of single fs_context
The fs_context free callback can be called multiple times for the
same fs_context data, once during fsmount() and then again when
the filesystem fd is closed. Deal with this by checking that
fc->fs_private is not null before freeing private data and setting
it to NULL when private data is freed.
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
diff --git a/fs/shiftfs.c b/fs/shiftfs.c
index 2885e3f..903f6fe 100644
--- a/fs/shiftfs.c
+++ b/fs/shiftfs.c
@@ -730,6 +730,10 @@ static void shiftfs_fs_context_free(struct fs_context *fc)
{
struct shiftfs_fs_context *ctx = fc->fs_private;
+ if (!ctx)
+ return;
+
+ fc->fs_private = NULL;
if (ctx->src_path) {
path_put(ctx->src_path);
kfree(ctx->src_path);