gpiolib: cdev: switch from kstrdup() to kstrndup()
authorKent Gibson <warthog618@gmail.com>
Mon, 5 Oct 2020 07:02:46 +0000 (15:02 +0800)
committerLinus Walleij <linus.walleij@linaro.org>
Thu, 8 Oct 2020 20:57:16 +0000 (22:57 +0200)
commitf188ac1251b909c2d804a6fee54e4e360754c92f
treeeacd83d158b0926a4bbfb47713af0dd7ec4e8be5
parent8c270fbceba4e13c992ac138e51db217c4844ed6
gpiolib: cdev: switch from kstrdup() to kstrndup()

Use kstrndup() to copy line labels from the userspace provided char
array, rather than ensuring the char array contains a null terminator
and using kstrdup().

Note that the length provided to kstrndup() still assumes that the char
array does contain a null terminator, so the maximum string length is one
less than the array.  This is consistent with the previous behaviour.

Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Link: https://lore.kernel.org/r/20201005070246.20927-1-warthog618@gmail.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpiolib-cdev.c