Skip to content

Commit

Permalink
nfs: Ignore kmemleak false positive in nfs_readdir_make_qstr
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
  • Loading branch information
Catalin Marinas authored and Trond Myklebust committed Nov 16, 2010
1 parent 94f58df commit 04e4bd1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions fs/nfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -238,6 +239,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;
}
Expand Down

0 comments on commit 04e4bd1

Please sign in to comment.