Skip to content

Commit c657c5d

Browse files
prati0100akpm00
authored andcommitted
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: b3749f1 ("mm: memfd_luo: allow preserving memfd") Signed-off-by: Pratyush Yadav (Google) <pratyush@kernel.org> Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com> Cc: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: Hugh Dickins <hughd@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 02e117b commit c657c5d

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

mm/memfd_luo.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,8 @@ static int memfd_luo_retrieve(struct liveupdate_file_op_args *args)
447447
file = memfd_alloc_file("", 0);
448448
if (IS_ERR(file)) {
449449
pr_err("failed to setup file: %pe\n", file);
450-
return PTR_ERR(file);
450+
err = PTR_ERR(file);
451+
goto free_ser;
451452
}
452453

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

474475
put_file:
475476
fput(file);
476-
477+
free_ser:
478+
kho_restore_free(ser);
477479
return err;
478480
}
479481

0 commit comments

Comments
 (0)