Commit b382a5c3 authored by Kees Cook's avatar Kees Cook Committed by Greg Kroah-Hartman

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: default avatarKees Cook <keescook@chromium.org>
Reviewed-by: default avatarKeith Packard <keithp@keithp.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 22072e83
...@@ -168,14 +168,10 @@ static int chaoskey_probe(struct usb_interface *interface, ...@@ -168,14 +168,10 @@ static int chaoskey_probe(struct usb_interface *interface,
*/ */
if (udev->product && udev->serial) { if (udev->product && udev->serial) {
dev->name = kmalloc(strlen(udev->product) + 1 + dev->name = kasprintf(GFP_KERNEL, "%s-%s", udev->product,
strlen(udev->serial) + 1, GFP_KERNEL); udev->serial);
if (dev->name == NULL) if (dev->name == NULL)
goto out; goto out;
strcpy(dev->name, udev->product);
strcat(dev->name, "-");
strcat(dev->name, udev->serial);
} }
dev->interface = interface; dev->interface = interface;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment