[PATCH] mm/memfd_luo: use real folio index in retrieve error logs

Giorgi Tchankvetadze giorgitchankvetadze1997 at gmail.com
Thu Aug 6 03:05:39 PDT 2026


From: Giorgi Tchankvetadze <giorgi at tchankvetadze.com>

memfd_luo_retrieve_folios() logs "folio index %ld" on its error paths
but passes the loop counter 'i' instead of the folio's actual index
held in the local 'index' variable (pfolio->index).

Pass 'index' to the three pr_err() calls so the logged index matches
the folio that actually failed. Since the saved index is a u64, use %llu with an
unsigned long long cast when printing it.

Fixes: b3749f174d68 ("mm: memfd_luo: allow preserving memfd")
Signed-off-by: Giorgi Tchankvetadze <giorgi at tchankvetadze.com>
---
 mm/memfd_luo.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/mm/memfd_luo.c b/mm/memfd_luo.c
index 59de210bee5f..652dd21e6ef0 100644
--- a/mm/memfd_luo.c
+++ b/mm/memfd_luo.c
@@ -451,16 +451,16 @@ static int memfd_luo_retrieve_folios(struct file *file,
 
 		err = mem_cgroup_charge(folio, NULL, mapping_gfp_mask(mapping));
 		if (err) {
-			pr_err("shmem: failed to charge folio index %ld: %d\n",
-			       i, err);
+			pr_err("shmem: failed to charge folio index %llu: %d\n",
+			       (unsigned long long)index, err);
 			goto unlock_folio;
 		}
 
 		err = shmem_add_to_page_cache(folio, mapping, index, NULL,
 					      mapping_gfp_mask(mapping));
 		if (err) {
-			pr_err("shmem: failed to add to page cache folio index %ld: %d\n",
-			       i, err);
+			pr_err("shmem: failed to add to page cache folio index %llu: %d\n",
+			       (unsigned long long)index, err);
 			goto unlock_folio;
 		}
 
@@ -472,8 +472,8 @@ static int memfd_luo_retrieve_folios(struct file *file,
 		npages = folio_nr_pages(folio);
 		err = shmem_inode_acct_blocks(inode, npages);
 		if (err) {
-			pr_err("shmem: failed to account folio index %ld(%ld pages): %d\n",
-			       i, npages, err);
+			pr_err("shmem: failed to account folio index %llu(%ld pages): %d\n",
+			       (unsigned long long)index, npages, err);
 			goto remove_from_cache;
 		}
 
-- 
2.52.0




More information about the kexec mailing list