NFSv4 only print the label when its queried
authorOlga Kornievskaia <kolga@netapp.com>
Mon, 29 Nov 2021 20:33:56 +0000 (15:33 -0500)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Thu, 6 Jan 2022 19:00:20 +0000 (14:00 -0500)
When the bitmask of the attributes doesn't include the security label,
don't bother printing it. Since the label might not be null terminated,
adjust the printing format accordingly.

Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
fs/nfs/nfs4xdr.c

index 69862bf6db0015cee29e0a7907ce9e728f157432..801119b7a59647282f790f9f91106d87e0f40dc5 100644 (file)
@@ -4200,10 +4200,11 @@ static int decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap,
                } else
                        printk(KERN_WARNING "%s: label too long (%u)!\n",
                                        __func__, len);
+               if (label && label->label)
+                       dprintk("%s: label=%.*s, len=%d, PI=%d, LFS=%d\n",
+                               __func__, label->len, (char *)label->label,
+                               label->len, label->pi, label->lfs);
        }
-       if (label && label->label)
-               dprintk("%s: label=%s, len=%d, PI=%d, LFS=%d\n", __func__,
-                       (char *)label->label, label->len, label->pi, label->lfs);
        return status;
 }