diff options
author | Kees Cook <keescook@chromium.org> | 2018-02-17 05:55:30 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-02-22 15:17:05 +0100 |
commit | b382a5c3c592a53cdf0097e314dc9936f7eae16d (patch) | |
tree | 8cfcaa3de37a4a302c203a6e5681d19af535195d | |
parent | usb: host: ehci: Use dma_pool_zalloc() (diff) | |
download | linux-b382a5c3c592a53cdf0097e314dc9936f7eae16d.tar.xz linux-b382a5c3c592a53cdf0097e314dc9936f7eae16d.zip |
USB: chaoskey: Use kasprintf() over strcpy()/strcat()
Instead of kmalloc() with manually calculated values followed by
multiple strcpy()/strcat() calls, just fold it all into a single
kasprintf() call.
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/usb/misc/chaoskey.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/drivers/usb/misc/chaoskey.c b/drivers/usb/misc/chaoskey.c index 716cb515523e..cf5828ce927a 100644 --- a/drivers/usb/misc/chaoskey.c +++ b/drivers/usb/misc/chaoskey.c @@ -168,14 +168,10 @@ static int chaoskey_probe(struct usb_interface *interface, */ if (udev->product && udev->serial) { - dev->name = kmalloc(strlen(udev->product) + 1 + - strlen(udev->serial) + 1, GFP_KERNEL); + dev->name = kasprintf(GFP_KERNEL, "%s-%s", udev->product, + udev->serial); if (dev->name == NULL) goto out; - - strcpy(dev->name, udev->product); - strcat(dev->name, "-"); - strcat(dev->name, udev->serial); } dev->interface = interface; |