mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-07 01:45:18 +02:00
nfsd: call cache_put if xdr_reserve_space returns NULL
[ Upstream commitd078cbf5c3
] If not enough buffer space available, but idmap_lookup has triggered lookup_fn which calls cache_get and returns successfully. Then we missed to call cache_put here which pairs with cache_get. Fixes:ddd1ea5636
("nfsd4: use xdr_reserve_space in attribute encoding") Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev> Reviwed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
b743922b5a
commit
a1afbbb527
|
@ -581,6 +581,7 @@ static __be32 idmap_id_to_name(struct xdr_stream *xdr,
|
||||||
.id = id,
|
.id = id,
|
||||||
.type = type,
|
.type = type,
|
||||||
};
|
};
|
||||||
|
__be32 status = nfs_ok;
|
||||||
__be32 *p;
|
__be32 *p;
|
||||||
int ret;
|
int ret;
|
||||||
struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
|
struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
|
||||||
|
@ -593,12 +594,16 @@ static __be32 idmap_id_to_name(struct xdr_stream *xdr,
|
||||||
return nfserrno(ret);
|
return nfserrno(ret);
|
||||||
ret = strlen(item->name);
|
ret = strlen(item->name);
|
||||||
WARN_ON_ONCE(ret > IDMAP_NAMESZ);
|
WARN_ON_ONCE(ret > IDMAP_NAMESZ);
|
||||||
|
|
||||||
p = xdr_reserve_space(xdr, ret + 4);
|
p = xdr_reserve_space(xdr, ret + 4);
|
||||||
if (!p)
|
if (unlikely(!p)) {
|
||||||
return nfserr_resource;
|
status = nfserr_resource;
|
||||||
p = xdr_encode_opaque(p, item->name, ret);
|
goto out_put;
|
||||||
|
}
|
||||||
|
xdr_encode_opaque(p, item->name, ret);
|
||||||
|
out_put:
|
||||||
cache_put(&item->h, nn->idtoname_cache);
|
cache_put(&item->h, nn->idtoname_cache);
|
||||||
return 0;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
|
Loading…
Reference in New Issue
Block a user