From: Trond Myklebust Date: Sun, 2 Feb 2020 22:53:55 +0000 (-0500) Subject: NFS: Use kmemdup_nul() in nfs_readdir_make_qstr() X-Git-Tag: v5.6-rc1~29^2~5 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=3803d6721baff3d5dd6cd6b8c7294e54d124bc41;p=users%2Fjedix%2Flinux-maple.git NFS: Use kmemdup_nul() in nfs_readdir_make_qstr() The directory strings stored in the readdir cache may be used with printk(), so it is better to ensure they are nul-terminated. Signed-off-by: Trond Myklebust Reviewed-by: Benjamin Coddington Signed-off-by: Anna Schumaker --- diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index d95c2c94bd87..5a8ff7e97ce3 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -198,7 +198,7 @@ static int nfs_readdir_make_qstr(struct qstr *string, const char *name, unsigned int len) { string->len = len; - string->name = kmemdup(name, len, GFP_KERNEL); + string->name = kmemdup_nul(name, len, GFP_KERNEL); if (string->name == NULL) return -ENOMEM; /*