]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: comedi: jr3_pci: use kasprintf
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Fri, 17 May 2013 18:16:12 +0000 (11:16 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 May 2013 19:09:48 +0000 (12:09 -0700)
kasprintf combines kmalloc and sprintf, and takes care of the size
calculation itself.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/jr3_pci.c

index c240e6d432cd70c9df479abb3cf08b187b6087fe..42e78d1e2ae92c781ce3d1a94c32c5274c66ff1f 100644 (file)
@@ -101,15 +101,11 @@ static int comedi_load_firmware(struct comedi_device *dev, const char *name,
        int result = 0;
        const struct firmware *fw;
        char *firmware_path;
-       static const char *prefix = "comedi/";
 
-       firmware_path = kmalloc(strlen(prefix) + strlen(name) + 1, GFP_KERNEL);
+       firmware_path = kasprintf(GFP_KERNEL, "comedi/%s", name);
        if (!firmware_path) {
                result = -ENOMEM;
        } else {
-               firmware_path[0] = '\0';
-               strcat(firmware_path, prefix);
-               strcat(firmware_path, name);
                result = request_firmware(&fw, firmware_path, &pcidev->dev);
                if (result == 0) {
                        if (!cb)