dm crypt: replace open-coded kmemdup_nul
authorJustin Stitt <justinstitt@google.com>
Mon, 25 Sep 2023 06:35:54 +0000 (06:35 +0000)
committerMike Snitzer <snitzer@kernel.org>
Mon, 23 Oct 2023 17:02:25 +0000 (13:02 -0400)
commite9d7bd2c8664aa43866c7985d9050a052516c07d
treef8970a1517e70b6562beb14df6aeb7c945c233f2
parentac4149ba7efd6bc327c1e15e812091984f3a16b2
dm crypt: replace open-coded kmemdup_nul

kzalloc() followed by strncpy() on an expected NUL-terminated string is
just kmemdup_nul(). Let's simplify this code (while also dropping a
deprecated strncpy() call [1]).

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings
Link: https://github.com/KSPP/linux/issues/90
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Justin Stitt <justinstitt@google.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
drivers/md/dm-crypt.c