[PATCH 3/3] mm: memfd_luo: restore and free memfd_luo_ser on failure

Pratyush Yadav posted 3 patches 2 weeks, 2 days ago
[PATCH 3/3] mm: memfd_luo: restore and free memfd_luo_ser on failure
Posted by Pratyush Yadav 2 weeks, 2 days ago
From: "Pratyush Yadav (Google)" <pratyush@kernel.org>

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

Fixes: b3749f174d68 ("mm: memfd_luo: allow preserving memfd")
Signed-off-by: Pratyush Yadav (Google) <pratyush@kernel.org>
---
 mm/memfd_luo.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/mm/memfd_luo.c b/mm/memfd_luo.c
index 01a72e4d3ef6..a34fccc23b6a 100644
--- a/mm/memfd_luo.c
+++ b/mm/memfd_luo.c
@@ -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;
 }
 
-- 
2.52.0.457.g6b5491de43-goog
Re: [PATCH 3/3] mm: memfd_luo: restore and free memfd_luo_ser on failure
Posted by Pasha Tatashin 2 weeks, 2 days ago
> ---
>  mm/memfd_luo.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/mm/memfd_luo.c b/mm/memfd_luo.c
> index 01a72e4d3ef6..a34fccc23b6a 100644
> --- a/mm/memfd_luo.c
> +++ b/mm/memfd_luo.c
> @@ -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);

Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Re: [PATCH 3/3] mm: memfd_luo: restore and free memfd_luo_ser on failure
Posted by Mike Rapoport 2 weeks, 2 days ago
On Thu, Jan 22, 2026 at 04:18:41PM +0100, Pratyush Yadav wrote:
> From: "Pratyush Yadav (Google)" <pratyush@kernel.org>
> 
> memfd_luo_ser has the serialization metadata. It is of no use once
> restoration fails. Free it on failure.
> 
> Fixes: b3749f174d68 ("mm: memfd_luo: allow preserving memfd")
> Signed-off-by: Pratyush Yadav (Google) <pratyush@kernel.org>

Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>

-- 
Sincerely yours,
Mike.