nfsd: call cache_put if xdr_reserve_space returns NULL
Subsystems (2)
PATCH 1/1 nfsd: call cache_put if xdr_reserve_space returns NULL
If no enough buffer space available, but idmap_lookup have triggered lookup_fn which calls cache_get and returns successfully. Then we missed to call cache_put here which pairs with cache_get.
--- fs/nfsd/nfs4idmap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/nfsd/nfs4idmap.c +3 -1
@@ -594,8 +594,10 @@ static __be32 idmap_id_to_name(struct xdr_stream *xdr, ret =strlen (item->name);WARN_ON_ONCE (ret >IDMAP_NAMESZ ); p =xdr_reserve_space (xdr, ret +4 ); -if (!p) +if (!p) { +cache_put (&item->h, nn->idtoname_cache);return nfserr_resource; + } p =xdr_encode_opaque (p, item->name, ret);cache_put (&item->h, nn->idtoname_cache);return 0 ;
Signature · 1 line
2.35.3
Chuck Lever
AppliedQuoted 5 lines · Guoqing Jiang
If no enough buffer space available, but
idmap_lookuphave triggeredlookup_fnwhich callscache_getand returns successfully. Then we missed to callcache_puthere which pairs withcache_get.
I've adjusted some aspects of the patch and added a Fixes: tag.
Applied to nfsd-next for v6.12, thanks!
[1/1] nfsd: call cache_put if xdr_reserve_space returns NULL
commit: ada7d1ab3aa1266b24d08aa4b3df93360a203924
Signature · 1 line
Chuck Lever
Quoted 7 lines · Chuck Lever
Quoted 5 lines · Guoqing Jiang
If no enough buffer space available, but
idmap_lookuphave triggeredlookup_fnwhich callscache_getand returns successfully. Then we missed to callcache_puthere which pairs withcache_get.I've adjusted some aspects of the patch and added a Fixes: tag.
Thanks for the modification!
Guoqing
Quoted 4 lines
Applied to nfsd-next for v6.12, thanks!
[1/1] nfsd: call
cache_putifxdr_reserve_spacereturns NULLcommit: ada7d1ab3aa1266b24d08aa4b3df93360a203924
Jeff Layton
maintainerQuoted 15 lines · Guoqing Jiang
If no enough buffer space available, but
idmap_lookuphave triggeredlookup_fnwhich callscache_getand returns successfully. Then we missed to callcache_puthere which pairs withcache_get.Signed-off-by Guoqing Jiang <[email protected]>--- fs/nfsd/nfs4idmap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)fs/nfsd/nfs4idmap.c +0
-0@@ -594,8 +594,10 @@ static __be32 idmap_id_to_name(struct xdr_stream *xdr, ret =strlen (item->name);
fs/nfsd/nfs4idmap.c static __be32 idmap_id_to_name(struct xdr_stream *xdr, · line 603
Quoted 10 lines
fs/nfsd/nfs4idmap.c +3
-1WARN_ON_ONCE (ret >IDMAP_NAMESZ ); p =xdr_reserve_space (xdr, ret +4 ); -if (!p) +if (!p) { +cache_put (&item->h, nn->idtoname_cache);return nfserr_resource; + } p =xdr_encode_opaque (p, item->name, ret);cache_put (&item->h, nn->idtoname_cache);return 0 ;
You can add this to the patch in Chuck's tree: