staging: dgap: Fix how we insure config data is a string
authorMark Hounschell <markh@compro.net>
Wed, 23 Apr 2014 14:33:44 +0000 (10:33 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 May 2014 19:15:18 +0000 (12:15 -0700)
This patch changes the way we insure the config data
is a string. Clearly this was just wrong. After a
certain number of loads/unloads various OOPs were
generated indicating something other than this driver
had a problem. It was this driver.

Signed-off-by: Mark Hounschell <markh@compro.net>
Tested-by: Mark Hounschell <markh@compro.net>
Reported-by: Mark Hounschell <markh@compro.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/dgap/dgap.c

index 3c9278a224e2b86fa5d398d44248e6f94135f72c..e0b8d0f051ccec3b1a0ac99d777d6d5a9de95d3d 100644 (file)
@@ -834,7 +834,7 @@ static int dgap_firmware_load(struct pci_dev *pdev, int card_type)
                        return ret;
                }
 
-               dgap_config_buf = kmalloc(fw->size + 1, GFP_KERNEL);
+               dgap_config_buf = kzalloc(fw->size + 1, GFP_KERNEL);
                if (!dgap_config_buf) {
                        release_firmware(fw);
                        return -ENOMEM;
@@ -842,7 +842,6 @@ static int dgap_firmware_load(struct pci_dev *pdev, int card_type)
 
                memcpy(dgap_config_buf, fw->data, fw->size);
                release_firmware(fw);
-               dgap_config_buf[fw->size + 1] = '\0';
 
                if (dgap_parsefile(&dgap_config_buf, TRUE) != 0) {
                        kfree(dgap_config_buf);