V4L/DVB (8842): vivi_release(): fix use-after-free
[safe/jmp/linux-2.6] / drivers / media / video / zr36016.c
index d4740a8..00d132b 100644 (file)
@@ -26,7 +26,6 @@
 
 #define ZR016_VERSION "v0.7"
 
-#include <linux/version.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/wait.h>
 
-/* includes for structures and defines regarding video 
+/* includes for structures and defines regarding video
    #include<linux/videodev.h> */
 
 /* I/O commands, error codes */
-#include<asm/io.h>
+#include <asm/io.h>
 //#include<errno.h>
 
 /* v4l  API */
-#include<linux/videodev.h>
+#include <linux/videodev.h>
 
 /* headerfile of this module */
 #include"zr36016.h"
 #define MAX_CODECS 20
 
 /* amount of chips attached via this driver */
-static int zr36016_codecs = 0;
+static int zr36016_codecs;
 
 /* debugging is available via module parameter */
-
-static int debug = 0;
+static int debug;
 module_param(debug, int, 0);
 MODULE_PARM_DESC(debug, "Debug level (0-4)");
 
@@ -144,8 +142,8 @@ zr36016_readi (struct zr36016 *ptr,
 
 static void
 zr36016_writei (struct zr36016 *ptr,
-               u16             reg,
-               u8              value)
+               u16             reg,
+               u8              value)
 {
        dprintk(4, "%s: writing indirect 0x%02x to 0x%04x\n", ptr->name,
                value, reg);
@@ -193,7 +191,7 @@ zr36016_basic_test (struct zr36016 *ptr)
                dprintk(1, "\n");
        }
        // for testing just write 0, then the default value to a register and read
-       // it back in both cases 
+       // it back in both cases
        zr36016_writei(ptr, ZR016I_PAX_LO, 0x00);
        if (zr36016_readi(ptr, ZR016I_PAX_LO) != 0x0) {
                dprintk(1,
@@ -233,17 +231,17 @@ zr36016_basic_test (struct zr36016 *ptr)
 static int zr36016_pushit (struct zr36016 *ptr,
                           u16             startreg,
                           u16             len,
-                           const char     *data)
+                          const char     *data)
 {
-        int i=0;
+       int i=0;
 
-        dprintk(4, "%s: write data block to 0x%04x (len=%d)\n",
+       dprintk(4, "%s: write data block to 0x%04x (len=%d)\n",
                ptr->name, startreg,len);
-        while (i<len) {
-                zr36016_writei(ptr, startreg++,  data[i++]);
-        }
+       while (i<len) {
+               zr36016_writei(ptr, startreg++,  data[i++]);
+       }
 
-        return i;
+       return i;
 }
 #endif
 
@@ -452,12 +450,11 @@ zr36016_setup (struct videocodec *codec)
                return -ENOSPC;
        }
        //mem structure init
-       codec->data = ptr = kmalloc(sizeof(struct zr36016), GFP_KERNEL);
+       codec->data = ptr = kzalloc(sizeof(struct zr36016), GFP_KERNEL);
        if (NULL == ptr) {
                dprintk(1, KERN_ERR "zr36016: Can't get enough memory!\n");
                return -ENOMEM;
        }
-       memset(ptr, 0, sizeof(struct zr36016));
 
        snprintf(ptr->name, sizeof(ptr->name), "zr36016[%d]",
                 zr36016_codecs);