Unverified Commit 5faf5aae authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!12318 nfsd: call cache_put if xdr_reserve_space returns NULL

parents 7aab0ca5 427a5df4
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -580,6 +580,7 @@ static __be32 idmap_id_to_name(struct xdr_stream *xdr,
		.id = id,
		.type = type,
	};
	__be32 status = nfs_ok;
	__be32 *p;
	int ret;
	struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
@@ -592,12 +593,16 @@ static __be32 idmap_id_to_name(struct xdr_stream *xdr,
		return nfserrno(ret);
	ret = strlen(item->name);
	WARN_ON_ONCE(ret > IDMAP_NAMESZ);

	p = xdr_reserve_space(xdr, ret + 4);
	if (!p)
		return nfserr_resource;
	p = xdr_encode_opaque(p, item->name, ret);
	if (unlikely(!p)) {
		status = nfserr_resource;
		goto out_put;
	}
	xdr_encode_opaque(p, item->name, ret);
out_put:
	cache_put(&item->h, nn->idtoname_cache);
	return 0;
	return status;
}

static bool