mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] efivarfs: Suppress false-positive kmemleak warning for sfi
@ 2025-07-15  9:28 Breno Leitao
  2025-07-16  0:41 ` Ard Biesheuvel
  0 siblings, 1 reply; 8+ messages in thread
From: Breno Leitao @ 2025-07-15  9:28 UTC (permalink / raw)
  To: Jeremy Kerr, Ard Biesheuvel
  Cc: linux-efi, linux-kernel, kernel-team, Breno Leitao

When kmemleak is enabled, it incorrectly reports the sfi structure
allocated during efivarfs_init_fs_context() as leaked:

    unreferenced object 0xffff888146250b80 (size 64):
    __kmalloc_cache_noprof
    efivarfs_init_fs_context
    ...

On module unload, this object is freed in efivarfs_kill_sb(), confirming
no actual leak. Also, kfree(sfi) is called at efivarfs_kill_sb(). I am
not able to explain why kmemleak detected it as a leak. To silence this
false-positive, mark the sfi allocation as ignored by kmemleak right
after allocation.

This ensures clearer leak diagnostics for this allocation path.

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 fs/efivarfs/super.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c
index c900d98bf4945..5f867ad2005ae 100644
--- a/fs/efivarfs/super.c
+++ b/fs/efivarfs/super.c
@@ -19,6 +19,7 @@
 #include <linux/notifier.h>
 #include <linux/printk.h>
 #include <linux/namei.h>
+#include <linux/kmemleak.h>
 
 #include "internal.h"
 #include "../internal.h"
@@ -498,6 +499,7 @@ static int efivarfs_init_fs_context(struct fs_context *fc)
 	if (!sfi)
 		return -ENOMEM;
 
+	kmemleak_ignore(sfi);
 	sfi->mount_opts.uid = GLOBAL_ROOT_UID;
 	sfi->mount_opts.gid = GLOBAL_ROOT_GID;
 

---
base-commit: 8c2e52ebbe885c7eeaabd3b7ddcdc1246fc400d2
change-id: 20250714-kmemleak_efi-bedfe48a304d

Best regards,
--  
Breno Leitao <leitao@debian.org>


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-07-16 14:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-15  9:28 [PATCH] efivarfs: Suppress false-positive kmemleak warning for sfi Breno Leitao
2025-07-16  0:41 ` Ard Biesheuvel
2025-07-16 11:45   ` Breno Leitao
2025-07-16 12:31     ` James Bottomley
2025-07-16 13:09       ` James Bottomley
2025-07-16 13:16         ` Breno Leitao
2025-07-16 13:26           ` James Bottomley
2025-07-16 14:30             ` Breno Leitao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®