* [PATCH] nfs: Ignore kmemleak false positive in nfs_readdir_make_qstr
@ 2010-11-11 12:53 Catalin Marinas
2010-11-11 14:51 ` Bryan Schumaker
0 siblings, 1 reply; 2+ messages in thread
From: Catalin Marinas @ 2010-11-11 12:53 UTC (permalink / raw)
To: linux-nfs; +Cc: linux-kernel, Bryan Schumaker, Trond Myklebust
Strings allocated via kmemdup() in nfs_readdir_make_qstr() are
referenced from the nfs_cache_array which is stored in a page cache
page. Kmemleak does not scan such pages and it reports several false
positives. This patch annotates the string->name pointer so that
kmemleak does not consider it a real leak.
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Bryan Schumaker <bjschuma@netapp.com>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
---
fs/nfs/dir.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 07ac384..a9f9e14 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -34,6 +34,7 @@
#include <linux/mount.h>
#include <linux/sched.h>
#include <linux/vmalloc.h>
+#include <linux/kmemleak.h>
#include "delegation.h"
#include "iostat.h"
@@ -231,6 +232,11 @@ int nfs_readdir_make_qstr(struct qstr *string, const char *name, unsigned int le
string->name = kmemdup(name, len, GFP_KERNEL);
if (string->name == NULL)
return -ENOMEM;
+ /*
+ * Avoid a kmemleak false positive. The pointer to the name is stored
+ * in a page cache page which kmemleak does not scan.
+ */
+ kmemleak_not_leak(string->name);
string->hash = full_name_hash(name, len);
return 0;
}
--
1.7.3.GIT
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] nfs: Ignore kmemleak false positive in nfs_readdir_make_qstr
2010-11-11 12:53 [PATCH] nfs: Ignore kmemleak false positive in nfs_readdir_make_qstr Catalin Marinas
@ 2010-11-11 14:51 ` Bryan Schumaker
0 siblings, 0 replies; 2+ messages in thread
From: Bryan Schumaker @ 2010-11-11 14:51 UTC (permalink / raw)
To: Catalin Marinas; +Cc: linux-nfs, linux-kernel, Trond Myklebust
Thanks! The patch works for me.
Bryan
On 11/11/2010 07:53 AM, Catalin Marinas wrote:
> Strings allocated via kmemdup() in nfs_readdir_make_qstr() are
> referenced from the nfs_cache_array which is stored in a page cache
> page. Kmemleak does not scan such pages and it reports several false
> positives. This patch annotates the string->name pointer so that
> kmemleak does not consider it a real leak.
>
> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Bryan Schumaker <bjschuma@netapp.com>
> Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
> ---
> fs/nfs/dir.c | 6 ++++++
> 1 files changed, 6 insertions(+), 0 deletions(-)
>
> diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
> index 07ac384..a9f9e14 100644
> --- a/fs/nfs/dir.c
> +++ b/fs/nfs/dir.c
> @@ -34,6 +34,7 @@
> #include <linux/mount.h>
> #include <linux/sched.h>
> #include <linux/vmalloc.h>
> +#include <linux/kmemleak.h>
>
> #include "delegation.h"
> #include "iostat.h"
> @@ -231,6 +232,11 @@ int nfs_readdir_make_qstr(struct qstr *string, const char *name, unsigned int le
> string->name = kmemdup(name, len, GFP_KERNEL);
> if (string->name == NULL)
> return -ENOMEM;
> + /*
> + * Avoid a kmemleak false positive. The pointer to the name is stored
> + * in a page cache page which kmemleak does not scan.
> + */
> + kmemleak_not_leak(string->name);
> string->hash = full_name_hash(name, len);
> return 0;
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-11-11 14:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-11 12:53 [PATCH] nfs: Ignore kmemleak false positive in nfs_readdir_make_qstr Catalin Marinas
2010-11-11 14:51 ` Bryan Schumaker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).