Commit c657c5dc authored by Pratyush Yadav (Google)'s avatar Pratyush Yadav (Google) Committed by Andrew Morton
Browse files

mm: memfd_luo: restore and free memfd_luo_ser on failure

memfd_luo_ser has the serialization metadata.  It is of no use once
restoration fails.  Free it on failure.

Link: https://lkml.kernel.org/r/20260122151842.4069702-4-pratyush@kernel.org


Fixes: b3749f17 ("mm: memfd_luo: allow preserving memfd")
Signed-off-by: default avatarPratyush Yadav (Google) <pratyush@kernel.org>
Reviewed-by: default avatarMike Rapoport (Microsoft) <rppt@kernel.org>
Reviewed-by: default avatarPasha Tatashin <pasha.tatashin@soleen.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 02e117b8
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -447,7 +447,8 @@ static int memfd_luo_retrieve(struct liveupdate_file_op_args *args)
	file = memfd_alloc_file("", 0);
	if (IS_ERR(file)) {
		pr_err("failed to setup file: %pe\n", file);
		return PTR_ERR(file);
		err = PTR_ERR(file);
		goto free_ser;
	}

	vfs_setpos(file, ser->pos, MAX_LFS_FILESIZE);
@@ -473,7 +474,8 @@ static int memfd_luo_retrieve(struct liveupdate_file_op_args *args)

put_file:
	fput(file);

free_ser:
	kho_restore_free(ser);
	return err;
}