]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.19.51/nfsd-avoid-uninitialized-variable-warning.patch
Linux 4.19.51
[thirdparty/kernel/stable-queue.git] / releases / 4.19.51 / nfsd-avoid-uninitialized-variable-warning.patch
CommitLineData
37554d48
SL
1From b43daa9f1d29e108520841d6dea0352e1d66a3d3 Mon Sep 17 00:00:00 2001
2From: Arnd Bergmann <arnd@arndb.de>
3Date: Fri, 22 Mar 2019 15:07:11 +0100
4Subject: nfsd: avoid uninitialized variable warning
5
6[ Upstream commit 0ab88ca4bcf18ba21058d8f19220f60afe0d34d8 ]
7
8clang warns that 'contextlen' may be accessed without an initialization:
9
10fs/nfsd/nfs4xdr.c:2911:9: error: variable 'contextlen' is uninitialized when used here [-Werror,-Wuninitialized]
11 contextlen);
12 ^~~~~~~~~~
13fs/nfsd/nfs4xdr.c:2424:16: note: initialize the variable 'contextlen' to silence this warning
14 int contextlen;
15 ^
16 = 0
17
18Presumably this cannot happen, as FATTR4_WORD2_SECURITY_LABEL is
19set if CONFIG_NFSD_V4_SECURITY_LABEL is enabled.
20Adding another #ifdef like the other two in this function
21avoids the warning.
22
23Signed-off-by: Arnd Bergmann <arnd@arndb.de>
24Signed-off-by: J. Bruce Fields <bfields@redhat.com>
25Signed-off-by: Sasha Levin <sashal@kernel.org>
26---
27 fs/nfsd/nfs4xdr.c | 4 ++++
28 1 file changed, 4 insertions(+)
29
30diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
31index 418fa9c78186..db0beefe65ec 100644
32--- a/fs/nfsd/nfs4xdr.c
33+++ b/fs/nfsd/nfs4xdr.c
34@@ -2413,8 +2413,10 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
35 __be32 status;
36 int err;
37 struct nfs4_acl *acl = NULL;
38+#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
39 void *context = NULL;
40 int contextlen;
41+#endif
42 bool contextsupport = false;
43 struct nfsd4_compoundres *resp = rqstp->rq_resp;
44 u32 minorversion = resp->cstate.minorversion;
45@@ -2899,12 +2901,14 @@ out_acl:
46 *p++ = cpu_to_be32(NFS4_CHANGE_TYPE_IS_TIME_METADATA);
47 }
48
49+#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
50 if (bmval2 & FATTR4_WORD2_SECURITY_LABEL) {
51 status = nfsd4_encode_security_label(xdr, rqstp, context,
52 contextlen);
53 if (status)
54 goto out;
55 }
56+#endif
57
58 attrlen = htonl(xdr->buf->len - attrlen_offset - 4);
59 write_bytes_to_xdr_buf(xdr->buf, attrlen_offset, &attrlen, 4);
60--
612.20.1
62