Provide a function to create a NUL-terminated string from unterminated data
authorDavid Howells <dhowells@redhat.com>
Tue, 4 Jul 2017 16:25:02 +0000 (17:25 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 25 Feb 2018 10:05:41 +0000 (11:05 +0100)
commit5cab144f072bdae16f37a06efb0dad210c7ff7bb
tree7df4d6b57798ff9d0e263f94fd420c3733c227d6
parent5fd4db305f2750418151d2d5553bfaec2956167a
Provide a function to create a NUL-terminated string from unterminated data

commit f35157417215ec138c920320c746fdb3e04ef1d5 upstream.

Provide a function, kmemdup_nul(), that will create a NUL-terminated string
from an unterminated character array where the length is known in advance.

This is better than kstrndup() in situations where we already know the
string length as the strnlen() in kstrndup() is superfluous.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/string.h
mm/util.c