staging/media/as102: Don't call release_firmware() on uninitialized variable
authorJesper Juhl <jj@chaosbits.net>
Sat, 24 Mar 2012 22:39:18 +0000 (23:39 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 10 Apr 2012 16:17:33 +0000 (09:17 -0700)
If, in drivers/staging/media/as102/as102_fw.c::as102_fw_upload(), the call
cmd_buf = kzalloc(MAX_FW_PKT_SIZE, GFP_KERNEL);
should fail and return NULL so that we jump to the 'error:' label,
then we'll end up calling 'release_firmware(firmware);' with
'firmware' still uninitialized - not good.

The easy fix is to just initialize 'firmware' to NULL when we declare
it, since release_firmware() deals gracefully with being passed NULL
pointers.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/media/as102/as102_fw.c

index 43ebc43e6b9a1e1841fcb3dc87e4811216359311..1075fb1df0d9c04a967634e56eb2e5a581d3421b 100644 (file)
@@ -165,7 +165,7 @@ error:
 int as102_fw_upload(struct as10x_bus_adapter_t *bus_adap)
 {
        int errno = -EFAULT;
-       const struct firmware *firmware;
+       const struct firmware *firmware = NULL;
        unsigned char *cmd_buf = NULL;
        char *fw1, *fw2;
        struct usb_device *dev = bus_adap->usb_dev;