aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesper Juhl <jesper.juhl@gmail.com>2005-09-10 03:26:54 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-10 13:06:30 -0400
commitf9101210e7aa72daf92722d451a2f7e3af5f781f (patch)
tree9554007e19387f2d05352ab03332be50c5b95f5b
parent887c27f369abc458556a5ce8ab22ddd498474307 (diff)
[PATCH] vfree and kfree cleanup in drivers/
This patch does a full cleanup of 'NULL checks before vfree', and a partial cleanup of calls to kfree for all of drivers/ - the kfree bit is partial in that I only did the files that also had vfree calls in them. The patch also gets rid of some redundant (void *) casts of pointers being passed to [vk]free, and a some tiny whitespace corrections also crept in. Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--drivers/block/z2ram.c2
-rw-r--r--drivers/cdrom/sbpcd.c6
-rw-r--r--drivers/char/agp/backend.c7
-rw-r--r--drivers/isdn/i4l/isdn_bsdcomp.c14
-rw-r--r--drivers/isdn/i4l/isdn_common.c3
-rw-r--r--drivers/md/dm-exception-store.c9
-rw-r--r--drivers/media/common/saa7146_core.c6
-rw-r--r--drivers/media/video/cpia_usb.c30
-rw-r--r--drivers/media/video/stradis.c32
-rw-r--r--drivers/media/video/video-buf.c8
-rw-r--r--drivers/media/video/zoran_driver.c2
-rw-r--r--drivers/media/video/zr36120.c6
-rw-r--r--drivers/mtd/devices/mtdram.c3
-rw-r--r--drivers/mtd/ftl.c11
-rw-r--r--drivers/net/bsd_comp.c28
-rw-r--r--drivers/scsi/53c7xx.c4
-rw-r--r--drivers/scsi/cpqfcTSinit.c3
-rw-r--r--drivers/scsi/osst.c13
-rw-r--r--drivers/usb/media/stv680.c26
-rw-r--r--drivers/video/vgastate.c15
20 files changed, 86 insertions, 142 deletions
diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c
index 007f6a662439..bb5e8d665a2a 100644
--- a/drivers/block/z2ram.c
+++ b/drivers/block/z2ram.c
@@ -296,7 +296,7 @@ z2_open( struct inode *inode, struct file *filp )
296 return 0; 296 return 0;
297 297
298err_out_kfree: 298err_out_kfree:
299 kfree( z2ram_map ); 299 kfree(z2ram_map);
300err_out: 300err_out:
301 return rc; 301 return rc;
302} 302}
diff --git a/drivers/cdrom/sbpcd.c b/drivers/cdrom/sbpcd.c
index 30a897755361..0b7d7412c4a5 100644
--- a/drivers/cdrom/sbpcd.c
+++ b/drivers/cdrom/sbpcd.c
@@ -4216,7 +4216,8 @@ static int sbpcd_dev_ioctl(struct cdrom_device_info *cdi, u_int cmd,
4216 4216
4217 case CDROMAUDIOBUFSIZ: /* configure the audio buffer size */ 4217 case CDROMAUDIOBUFSIZ: /* configure the audio buffer size */
4218 msg(DBG_IOC,"ioctl: CDROMAUDIOBUFSIZ entered.\n"); 4218 msg(DBG_IOC,"ioctl: CDROMAUDIOBUFSIZ entered.\n");
4219 if (current_drive->sbp_audsiz>0) vfree(current_drive->aud_buf); 4219 if (current_drive->sbp_audsiz>0)
4220 vfree(current_drive->aud_buf);
4220 current_drive->aud_buf=NULL; 4221 current_drive->aud_buf=NULL;
4221 current_drive->sbp_audsiz=arg; 4222 current_drive->sbp_audsiz=arg;
4222 4223
@@ -5910,7 +5911,8 @@ static void sbpcd_exit(void)
5910 put_disk(D_S[j].disk); 5911 put_disk(D_S[j].disk);
5911 devfs_remove("sbp/c0t%d", j); 5912 devfs_remove("sbp/c0t%d", j);
5912 vfree(D_S[j].sbp_buf); 5913 vfree(D_S[j].sbp_buf);
5913 if (D_S[j].sbp_audsiz>0) vfree(D_S[j].aud_buf); 5914 if (D_S[j].sbp_audsiz>0)
5915 vfree(D_S[j].aud_buf);
5914 if ((unregister_cdrom(D_S[j].sbpcd_infop) == -EINVAL)) 5916 if ((unregister_cdrom(D_S[j].sbpcd_infop) == -EINVAL))
5915 { 5917 {
5916 msg(DBG_INF, "What's that: can't unregister info %s.\n", major_name); 5918 msg(DBG_INF, "What's that: can't unregister info %s.\n", major_name);
diff --git a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c
index 4d4e602fdc7e..82b43c541c8d 100644
--- a/drivers/char/agp/backend.c
+++ b/drivers/char/agp/backend.c
@@ -206,10 +206,9 @@ static void agp_backend_cleanup(struct agp_bridge_data *bridge)
206 bridge->driver->cleanup(); 206 bridge->driver->cleanup();
207 if (bridge->driver->free_gatt_table) 207 if (bridge->driver->free_gatt_table)
208 bridge->driver->free_gatt_table(bridge); 208 bridge->driver->free_gatt_table(bridge);
209 if (bridge->key_list) { 209
210 vfree(bridge->key_list); 210 vfree(bridge->key_list);
211 bridge->key_list = NULL; 211 bridge->key_list = NULL;
212 }
213 212
214 if (bridge->driver->agp_destroy_page && 213 if (bridge->driver->agp_destroy_page &&
215 bridge->driver->needs_scratch_page) 214 bridge->driver->needs_scratch_page)
diff --git a/drivers/isdn/i4l/isdn_bsdcomp.c b/drivers/isdn/i4l/isdn_bsdcomp.c
index baf4bcad9bf9..0afe442db3b0 100644
--- a/drivers/isdn/i4l/isdn_bsdcomp.c
+++ b/drivers/isdn/i4l/isdn_bsdcomp.c
@@ -283,23 +283,19 @@ static void bsd_free (void *state)
283 /* 283 /*
284 * Release the dictionary 284 * Release the dictionary
285 */ 285 */
286 if (db->dict) { 286 vfree(db->dict);
287 vfree (db->dict); 287 db->dict = NULL;
288 db->dict = NULL;
289 }
290 288
291 /* 289 /*
292 * Release the string buffer 290 * Release the string buffer
293 */ 291 */
294 if (db->lens) { 292 vfree(db->lens);
295 vfree (db->lens); 293 db->lens = NULL;
296 db->lens = NULL;
297 }
298 294
299 /* 295 /*
300 * Finally release the structure itself. 296 * Finally release the structure itself.
301 */ 297 */
302 kfree (db); 298 kfree(db);
303 } 299 }
304} 300}
305 301
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
index eebcb0b97f0e..8a7d54a5c97d 100644
--- a/drivers/isdn/i4l/isdn_common.c
+++ b/drivers/isdn/i4l/isdn_common.c
@@ -1953,7 +1953,8 @@ isdn_add_channels(isdn_driver_t *d, int drvidx, int n, int adding)
1953 kfree(d->rcvcount); 1953 kfree(d->rcvcount);
1954 if (!(d->rcvcount = kmalloc(sizeof(int) * m, GFP_ATOMIC))) { 1954 if (!(d->rcvcount = kmalloc(sizeof(int) * m, GFP_ATOMIC))) {
1955 printk(KERN_WARNING "register_isdn: Could not alloc rcvcount\n"); 1955 printk(KERN_WARNING "register_isdn: Could not alloc rcvcount\n");
1956 if (!adding) kfree(d->rcverr); 1956 if (!adding)
1957 kfree(d->rcverr);
1957 return -1; 1958 return -1;
1958 } 1959 }
1959 memset((char *) d->rcvcount, 0, sizeof(int) * m); 1960 memset((char *) d->rcvcount, 0, sizeof(int) * m);
diff --git a/drivers/md/dm-exception-store.c b/drivers/md/dm-exception-store.c
index 17212b4201a1..cc07bbebbb16 100644
--- a/drivers/md/dm-exception-store.c
+++ b/drivers/md/dm-exception-store.c
@@ -568,12 +568,9 @@ int dm_create_persistent(struct exception_store *store, uint32_t chunk_size)
568 568
569 bad: 569 bad:
570 dm_io_put(sectors_to_pages(chunk_size)); 570 dm_io_put(sectors_to_pages(chunk_size));
571 if (ps) { 571 if (ps && ps->area)
572 if (ps->area) 572 free_area(ps);
573 free_area(ps); 573 kfree(ps);
574
575 kfree(ps);
576 }
577 return r; 574 return r;
578} 575}
579 576
diff --git a/drivers/media/common/saa7146_core.c b/drivers/media/common/saa7146_core.c
index cd5828b5e9e3..206cc2f61f26 100644
--- a/drivers/media/common/saa7146_core.c
+++ b/drivers/media/common/saa7146_core.c
@@ -168,10 +168,8 @@ void saa7146_pgtable_free(struct pci_dev *pci, struct saa7146_pgtable *pt)
168 return; 168 return;
169 pci_free_consistent(pci, pt->size, pt->cpu, pt->dma); 169 pci_free_consistent(pci, pt->size, pt->cpu, pt->dma);
170 pt->cpu = NULL; 170 pt->cpu = NULL;
171 if (NULL != pt->slist) { 171 kfree(pt->slist);
172 kfree(pt->slist); 172 pt->slist = NULL;
173 pt->slist = NULL;
174 }
175} 173}
176 174
177int saa7146_pgtable_alloc(struct pci_dev *pci, struct saa7146_pgtable *pt) 175int saa7146_pgtable_alloc(struct pci_dev *pci, struct saa7146_pgtable *pt)
diff --git a/drivers/media/video/cpia_usb.c b/drivers/media/video/cpia_usb.c
index cdda423386c5..9774e94d1e7d 100644
--- a/drivers/media/video/cpia_usb.c
+++ b/drivers/media/video/cpia_usb.c
@@ -445,10 +445,8 @@ static void cpia_usb_free_resources(struct usb_cpia *ucpia, int try)
445 ucpia->sbuf[1].urb = NULL; 445 ucpia->sbuf[1].urb = NULL;
446 } 446 }
447 447
448 if (ucpia->sbuf[1].data) { 448 kfree(ucpia->sbuf[1].data);
449 kfree(ucpia->sbuf[1].data); 449 ucpia->sbuf[1].data = NULL;
450 ucpia->sbuf[1].data = NULL;
451 }
452 450
453 if (ucpia->sbuf[0].urb) { 451 if (ucpia->sbuf[0].urb) {
454 usb_kill_urb(ucpia->sbuf[0].urb); 452 usb_kill_urb(ucpia->sbuf[0].urb);
@@ -456,10 +454,8 @@ static void cpia_usb_free_resources(struct usb_cpia *ucpia, int try)
456 ucpia->sbuf[0].urb = NULL; 454 ucpia->sbuf[0].urb = NULL;
457 } 455 }
458 456
459 if (ucpia->sbuf[0].data) { 457 kfree(ucpia->sbuf[0].data);
460 kfree(ucpia->sbuf[0].data); 458 ucpia->sbuf[0].data = NULL;
461 ucpia->sbuf[0].data = NULL;
462 }
463} 459}
464 460
465static int cpia_usb_close(void *privdata) 461static int cpia_usb_close(void *privdata)
@@ -623,20 +619,14 @@ static void cpia_disconnect(struct usb_interface *intf)
623 619
624 ucpia->curbuff = ucpia->workbuff = NULL; 620 ucpia->curbuff = ucpia->workbuff = NULL;
625 621
626 if (ucpia->buffers[2]) { 622 vfree(ucpia->buffers[2]);
627 vfree(ucpia->buffers[2]); 623 ucpia->buffers[2] = NULL;
628 ucpia->buffers[2] = NULL;
629 }
630 624
631 if (ucpia->buffers[1]) { 625 vfree(ucpia->buffers[1]);
632 vfree(ucpia->buffers[1]); 626 ucpia->buffers[1] = NULL;
633 ucpia->buffers[1] = NULL;
634 }
635 627
636 if (ucpia->buffers[0]) { 628 vfree(ucpia->buffers[0]);
637 vfree(ucpia->buffers[0]); 629 ucpia->buffers[0] = NULL;
638 ucpia->buffers[0] = NULL;
639 }
640 630
641 cam->lowlevel_data = NULL; 631 cam->lowlevel_data = NULL;
642 kfree(ucpia); 632 kfree(ucpia);
diff --git a/drivers/media/video/stradis.c b/drivers/media/video/stradis.c
index b57743571087..d4497dbae05c 100644
--- a/drivers/media/video/stradis.c
+++ b/drivers/media/video/stradis.c
@@ -2184,30 +2184,18 @@ static void release_saa(void)
2184 vfree(saa->vidbuf); 2184 vfree(saa->vidbuf);
2185 vfree(saa->audbuf); 2185 vfree(saa->audbuf);
2186 vfree(saa->osdbuf); 2186 vfree(saa->osdbuf);
2187 if (saa->dmavid2) 2187 kfree(saa->dmavid2);
2188 kfree((void *) saa->dmavid2);
2189 saa->audbuf = saa->vidbuf = saa->osdbuf = NULL; 2188 saa->audbuf = saa->vidbuf = saa->osdbuf = NULL;
2190 saa->dmavid2 = NULL; 2189 saa->dmavid2 = NULL;
2191 if (saa->dmadebi) 2190 kfree(saa->dmadebi);
2192 kfree((void *) saa->dmadebi); 2191 kfree(saa->dmavid1);
2193 if (saa->dmavid1) 2192 kfree(saa->dmavid3);
2194 kfree((void *) saa->dmavid1); 2193 kfree(saa->dmaa1in);
2195 if (saa->dmavid2) 2194 kfree(saa->dmaa1out);
2196 kfree((void *) saa->dmavid2); 2195 kfree(saa->dmaa2in);
2197 if (saa->dmavid3) 2196 kfree(saa->dmaa2out);
2198 kfree((void *) saa->dmavid3); 2197 kfree(saa->dmaRPS1);
2199 if (saa->dmaa1in) 2198 kfree(saa->dmaRPS2);
2200 kfree((void *) saa->dmaa1in);
2201 if (saa->dmaa1out)
2202 kfree((void *) saa->dmaa1out);
2203 if (saa->dmaa2in)
2204 kfree((void *) saa->dmaa2in);
2205 if (saa->dmaa2out)
2206 kfree((void *) saa->dmaa2out);
2207 if (saa->dmaRPS1)
2208 kfree((void *) saa->dmaRPS1);
2209 if (saa->dmaRPS2)
2210 kfree((void *) saa->dmaRPS2);
2211 free_irq(saa->irq, saa); 2199 free_irq(saa->irq, saa);
2212 if (saa->saa7146_mem) 2200 if (saa->saa7146_mem)
2213 iounmap(saa->saa7146_mem); 2201 iounmap(saa->saa7146_mem);
diff --git a/drivers/media/video/video-buf.c b/drivers/media/video/video-buf.c
index 97354f253a80..574b8e36f3c6 100644
--- a/drivers/media/video/video-buf.c
+++ b/drivers/media/video/video-buf.c
@@ -267,10 +267,10 @@ int videobuf_dma_free(struct videobuf_dmabuf *dma)
267 kfree(dma->pages); 267 kfree(dma->pages);
268 dma->pages = NULL; 268 dma->pages = NULL;
269 } 269 }
270 if (dma->vmalloc) { 270
271 vfree(dma->vmalloc); 271 vfree(dma->vmalloc);
272 dma->vmalloc = NULL; 272 dma->vmalloc = NULL;
273 } 273
274 if (dma->bus_addr) { 274 if (dma->bus_addr) {
275 dma->bus_addr = 0; 275 dma->bus_addr = 0;
276 } 276 }
diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c
index ba838a42ec80..53adeb70f2ca 100644
--- a/drivers/media/video/zoran_driver.c
+++ b/drivers/media/video/zoran_driver.c
@@ -650,7 +650,7 @@ jpg_fbuffer_free (struct file *file)
650 off += PAGE_SIZE) 650 off += PAGE_SIZE)
651 ClearPageReserved(MAP_NR 651 ClearPageReserved(MAP_NR
652 (mem + off)); 652 (mem + off));
653 kfree((void *) mem); 653 kfree(mem);
654 fh->jpg_buffers.buffer[i].frag_tab[0] = 0; 654 fh->jpg_buffers.buffer[i].frag_tab[0] = 0;
655 fh->jpg_buffers.buffer[i].frag_tab[1] = 0; 655 fh->jpg_buffers.buffer[i].frag_tab[1] = 0;
656 } 656 }
diff --git a/drivers/media/video/zr36120.c b/drivers/media/video/zr36120.c
index c33533155cc7..07286816d7df 100644
--- a/drivers/media/video/zr36120.c
+++ b/drivers/media/video/zr36120.c
@@ -820,11 +820,9 @@ void zoran_close(struct video_device* dev)
820 msleep(100); /* Wait 1/10th of a second */ 820 msleep(100); /* Wait 1/10th of a second */
821 821
822 /* free the allocated framebuffer */ 822 /* free the allocated framebuffer */
823 if (ztv->fbuffer) 823 bfree(ztv->fbuffer, ZORAN_MAX_FBUFSIZE);
824 bfree( ztv->fbuffer, ZORAN_MAX_FBUFSIZE );
825 ztv->fbuffer = 0; 824 ztv->fbuffer = 0;
826 if (ztv->overinfo.overlay) 825 kfree(ztv->overinfo.overlay);
827 kfree( ztv->overinfo.overlay );
828 ztv->overinfo.overlay = 0; 826 ztv->overinfo.overlay = 0;
829 827
830} 828}
diff --git a/drivers/mtd/devices/mtdram.c b/drivers/mtd/devices/mtdram.c
index bb713fed2f37..1443117fd8f4 100644
--- a/drivers/mtd/devices/mtdram.c
+++ b/drivers/mtd/devices/mtdram.c
@@ -91,8 +91,7 @@ static void __exit cleanup_mtdram(void)
91{ 91{
92 if (mtd_info) { 92 if (mtd_info) {
93 del_mtd_device(mtd_info); 93 del_mtd_device(mtd_info);
94 if (mtd_info->priv) 94 vfree(mtd_info->priv);
95 vfree(mtd_info->priv);
96 kfree(mtd_info); 95 kfree(mtd_info);
97 } 96 }
98} 97}
diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c
index d9ab60b36fd4..d32c1b3a8ce3 100644
--- a/drivers/mtd/ftl.c
+++ b/drivers/mtd/ftl.c
@@ -1017,27 +1017,16 @@ static int ftl_writesect(struct mtd_blktrans_dev *dev,
1017 1017
1018void ftl_freepart(partition_t *part) 1018void ftl_freepart(partition_t *part)
1019{ 1019{
1020 if (part->VirtualBlockMap) {
1021 vfree(part->VirtualBlockMap); 1020 vfree(part->VirtualBlockMap);
1022 part->VirtualBlockMap = NULL; 1021 part->VirtualBlockMap = NULL;
1023 }
1024 if (part->VirtualPageMap) {
1025 kfree(part->VirtualPageMap); 1022 kfree(part->VirtualPageMap);
1026 part->VirtualPageMap = NULL; 1023 part->VirtualPageMap = NULL;
1027 }
1028 if (part->EUNInfo) {
1029 kfree(part->EUNInfo); 1024 kfree(part->EUNInfo);
1030 part->EUNInfo = NULL; 1025 part->EUNInfo = NULL;
1031 }
1032 if (part->XferInfo) {
1033 kfree(part->XferInfo); 1026 kfree(part->XferInfo);
1034 part->XferInfo = NULL; 1027 part->XferInfo = NULL;
1035 }
1036 if (part->bam_cache) {
1037 kfree(part->bam_cache); 1028 kfree(part->bam_cache);
1038 part->bam_cache = NULL; 1029 part->bam_cache = NULL;
1039 }
1040
1041} /* ftl_freepart */ 1030} /* ftl_freepart */
1042 1031
1043static void ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) 1032static void ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
diff --git a/drivers/net/bsd_comp.c b/drivers/net/bsd_comp.c
index 3d88ad622bdb..fb4098ed469e 100644
--- a/drivers/net/bsd_comp.c
+++ b/drivers/net/bsd_comp.c
@@ -323,33 +323,27 @@ static void bsd_reset (void *state)
323 */ 323 */
324 324
325static void bsd_free (void *state) 325static void bsd_free (void *state)
326 { 326{
327 struct bsd_db *db = (struct bsd_db *) state; 327 struct bsd_db *db = state;
328 328
329 if (db) 329 if (!db)
330 { 330 return;
331
331/* 332/*
332 * Release the dictionary 333 * Release the dictionary
333 */ 334 */
334 if (db->dict) 335 vfree(db->dict);
335 { 336 db->dict = NULL;
336 vfree (db->dict);
337 db->dict = NULL;
338 }
339/* 337/*
340 * Release the string buffer 338 * Release the string buffer
341 */ 339 */
342 if (db->lens) 340 vfree(db->lens);
343 { 341 db->lens = NULL;
344 vfree (db->lens);
345 db->lens = NULL;
346 }
347/* 342/*
348 * Finally release the structure itself. 343 * Finally release the structure itself.
349 */ 344 */
350 kfree (db); 345 kfree(db);
351 } 346}
352 }
353 347
354/* 348/*
355 * Allocate space for a (de) compressor. 349 * Allocate space for a (de) compressor.
diff --git a/drivers/scsi/53c7xx.c b/drivers/scsi/53c7xx.c
index 2341d27ceed7..7a33c708f5b3 100644
--- a/drivers/scsi/53c7xx.c
+++ b/drivers/scsi/53c7xx.c
@@ -6090,8 +6090,8 @@ NCR53c7x0_release(struct Scsi_Host *host) {
6090 if (hostdata->num_cmds) 6090 if (hostdata->num_cmds)
6091 printk ("scsi%d : leaked %d NCR53c7x0_cmd structures\n", 6091 printk ("scsi%d : leaked %d NCR53c7x0_cmd structures\n",
6092 host->host_no, hostdata->num_cmds); 6092 host->host_no, hostdata->num_cmds);
6093 if (hostdata->events) 6093
6094 vfree ((void *)hostdata->events); 6094 vfree(hostdata->events);
6095 6095
6096 /* XXX This assumes default cache mode to be IOMAP_FULL_CACHING, which 6096 /* XXX This assumes default cache mode to be IOMAP_FULL_CACHING, which
6097 * XXX may be invalid (CONFIG_060_WRITETHROUGH) 6097 * XXX may be invalid (CONFIG_060_WRITETHROUGH)
diff --git a/drivers/scsi/cpqfcTSinit.c b/drivers/scsi/cpqfcTSinit.c
index d72be0ce89c8..3fda8d455c5b 100644
--- a/drivers/scsi/cpqfcTSinit.c
+++ b/drivers/scsi/cpqfcTSinit.c
@@ -691,8 +691,7 @@ int cpqfcTS_ioctl( struct scsi_device *ScsiDev, int Cmnd, void *arg)
691 if( copy_to_user( vendor_cmd->bufp, buf, vendor_cmd->len)) 691 if( copy_to_user( vendor_cmd->bufp, buf, vendor_cmd->len))
692 result = -EFAULT; 692 result = -EFAULT;
693 693
694 if( buf) 694 kfree(buf);
695 kfree( buf);
696 695
697 return result; 696 return result;
698 } 697 }
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index 89a4a0615c22..3f2f2464fa63 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -1377,7 +1377,7 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct scsi
1377 1377
1378 if ((STp->buffer)->syscall_result || !SRpnt) { 1378 if ((STp->buffer)->syscall_result || !SRpnt) {
1379 printk(KERN_ERR "%s:E: Failed to read frame back from OnStream buffer\n", name); 1379 printk(KERN_ERR "%s:E: Failed to read frame back from OnStream buffer\n", name);
1380 vfree((void *)buffer); 1380 vfree(buffer);
1381 *aSRpnt = SRpnt; 1381 *aSRpnt = SRpnt;
1382 return (-EIO); 1382 return (-EIO);
1383 } 1383 }
@@ -1419,7 +1419,7 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct scsi
1419 1419
1420 if (new_frame > frame + 1000) { 1420 if (new_frame > frame + 1000) {
1421 printk(KERN_ERR "%s:E: Failed to find writable tape media\n", name); 1421 printk(KERN_ERR "%s:E: Failed to find writable tape media\n", name);
1422 vfree((void *)buffer); 1422 vfree(buffer);
1423 return (-EIO); 1423 return (-EIO);
1424 } 1424 }
1425 if ( i >= nframes + pending ) break; 1425 if ( i >= nframes + pending ) break;
@@ -1500,7 +1500,7 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct scsi
1500 SRpnt->sr_sense_buffer[12] == 0 && 1500 SRpnt->sr_sense_buffer[12] == 0 &&
1501 SRpnt->sr_sense_buffer[13] == 2) { 1501 SRpnt->sr_sense_buffer[13] == 2) {
1502 printk(KERN_ERR "%s:E: Volume overflow in write error recovery\n", name); 1502 printk(KERN_ERR "%s:E: Volume overflow in write error recovery\n", name);
1503 vfree((void *)buffer); 1503 vfree(buffer);
1504 return (-EIO); /* hit end of tape = fail */ 1504 return (-EIO); /* hit end of tape = fail */
1505 } 1505 }
1506 i = ((SRpnt->sr_sense_buffer[3] << 24) | 1506 i = ((SRpnt->sr_sense_buffer[3] << 24) |
@@ -1525,7 +1525,7 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct scsi
1525 } 1525 }
1526 if (!pending) 1526 if (!pending)
1527 osst_copy_to_buffer(STp->buffer, p); /* so buffer content == at entry in all cases */ 1527 osst_copy_to_buffer(STp->buffer, p); /* so buffer content == at entry in all cases */
1528 vfree((void *)buffer); 1528 vfree(buffer);
1529 return 0; 1529 return 0;
1530} 1530}
1531 1531
@@ -5852,7 +5852,7 @@ static int osst_remove(struct device *dev)
5852 os_scsi_tapes[i] = NULL; 5852 os_scsi_tapes[i] = NULL;
5853 osst_nr_dev--; 5853 osst_nr_dev--;
5854 write_unlock(&os_scsi_tapes_lock); 5854 write_unlock(&os_scsi_tapes_lock);
5855 if (tpnt->header_cache != NULL) vfree(tpnt->header_cache); 5855 vfree(tpnt->header_cache);
5856 if (tpnt->buffer) { 5856 if (tpnt->buffer) {
5857 normalize_buffer(tpnt->buffer); 5857 normalize_buffer(tpnt->buffer);
5858 kfree(tpnt->buffer); 5858 kfree(tpnt->buffer);
@@ -5896,8 +5896,7 @@ static void __exit exit_osst (void)
5896 for (i=0; i < osst_max_dev; ++i) { 5896 for (i=0; i < osst_max_dev; ++i) {
5897 if (!(STp = os_scsi_tapes[i])) continue; 5897 if (!(STp = os_scsi_tapes[i])) continue;
5898 /* This is defensive, supposed to happen during detach */ 5898 /* This is defensive, supposed to happen during detach */
5899 if (STp->header_cache) 5899 vfree(STp->header_cache);
5900 vfree(STp->header_cache);
5901 if (STp->buffer) { 5900 if (STp->buffer) {
5902 normalize_buffer(STp->buffer); 5901 normalize_buffer(STp->buffer);
5903 kfree(STp->buffer); 5902 kfree(STp->buffer);
diff --git a/drivers/usb/media/stv680.c b/drivers/usb/media/stv680.c
index 7398a7f19c1e..0fd0fa9fec21 100644
--- a/drivers/usb/media/stv680.c
+++ b/drivers/usb/media/stv680.c
@@ -260,7 +260,7 @@ static int stv_stop_video (struct usb_stv *dev)
260 PDEBUG (0, "STV(i): Camera set to original resolution"); 260 PDEBUG (0, "STV(i): Camera set to original resolution");
261 } 261 }
262 /* origMode */ 262 /* origMode */
263 kfree (buf); 263 kfree(buf);
264 return i; 264 return i;
265} 265}
266 266
@@ -276,7 +276,7 @@ static int stv_set_video_mode (struct usb_stv *dev)
276 } 276 }
277 277
278 if ((i = stv_set_config (dev, 1, 0, 0)) < 0) { 278 if ((i = stv_set_config (dev, 1, 0, 0)) < 0) {
279 kfree (buf); 279 kfree(buf);
280 return i; 280 return i;
281 } 281 }
282 282
@@ -301,13 +301,13 @@ static int stv_set_video_mode (struct usb_stv *dev)
301 goto exit; 301 goto exit;
302 302
303error: 303error:
304 kfree (buf); 304 kfree(buf);
305 if (stop_video == 1) 305 if (stop_video == 1)
306 stv_stop_video (dev); 306 stv_stop_video (dev);
307 return -1; 307 return -1;
308 308
309exit: 309exit:
310 kfree (buf); 310 kfree(buf);
311 return 0; 311 return 0;
312} 312}
313 313
@@ -327,7 +327,7 @@ static int stv_init (struct usb_stv *stv680)
327 327
328 /* set config 1, interface 0, alternate 0 */ 328 /* set config 1, interface 0, alternate 0 */
329 if ((i = stv_set_config (stv680, 1, 0, 0)) < 0) { 329 if ((i = stv_set_config (stv680, 1, 0, 0)) < 0) {
330 kfree (buffer); 330 kfree(buffer);
331 PDEBUG (0, "STV(e): set config 1,0,0 failed"); 331 PDEBUG (0, "STV(e): set config 1,0,0 failed");
332 return -1; 332 return -1;
333 } 333 }
@@ -435,11 +435,11 @@ static int stv_init (struct usb_stv *stv680)
435error: 435error:
436 i = stv_sndctrl (0, stv680, 0x80, 0, buffer, 0x02); /* Get Last Error */ 436 i = stv_sndctrl (0, stv680, 0x80, 0, buffer, 0x02); /* Get Last Error */
437 PDEBUG (1, "STV(i): last error: %i, command = 0x%x", buffer[0], buffer[1]); 437 PDEBUG (1, "STV(i): last error: %i, command = 0x%x", buffer[0], buffer[1]);
438 kfree (buffer); 438 kfree(buffer);
439 return -1; 439 return -1;
440 440
441exit: 441exit:
442 kfree (buffer); 442 kfree(buffer);
443 443
444 /* video = 320x240, 352x288 */ 444 /* video = 320x240, 352x288 */
445 if (stv680->CIF == 1) { 445 if (stv680->CIF == 1) {
@@ -708,10 +708,10 @@ static int stv680_stop_stream (struct usb_stv *stv680)
708 usb_kill_urb (stv680->urb[i]); 708 usb_kill_urb (stv680->urb[i]);
709 usb_free_urb (stv680->urb[i]); 709 usb_free_urb (stv680->urb[i]);
710 stv680->urb[i] = NULL; 710 stv680->urb[i] = NULL;
711 kfree (stv680->sbuf[i].data); 711 kfree(stv680->sbuf[i].data);
712 } 712 }
713 for (i = 0; i < STV680_NUMSCRATCH; i++) { 713 for (i = 0; i < STV680_NUMSCRATCH; i++) {
714 kfree (stv680->scratch[i].data); 714 kfree(stv680->scratch[i].data);
715 stv680->scratch[i].data = NULL; 715 stv680->scratch[i].data = NULL;
716 } 716 }
717 717
@@ -1068,7 +1068,7 @@ static int stv_close (struct inode *inode, struct file *file)
1068 stv680->user = 0; 1068 stv680->user = 0;
1069 1069
1070 if (stv680->removed) { 1070 if (stv680->removed) {
1071 kfree (stv680); 1071 kfree(stv680);
1072 stv680 = NULL; 1072 stv680 = NULL;
1073 PDEBUG (0, "STV(i): device unregistered"); 1073 PDEBUG (0, "STV(i): device unregistered");
1074 } 1074 }
@@ -1445,14 +1445,14 @@ static inline void usb_stv680_remove_disconnected (struct usb_stv *stv680)
1445 usb_kill_urb (stv680->urb[i]); 1445 usb_kill_urb (stv680->urb[i]);
1446 usb_free_urb (stv680->urb[i]); 1446 usb_free_urb (stv680->urb[i]);
1447 stv680->urb[i] = NULL; 1447 stv680->urb[i] = NULL;
1448 kfree (stv680->sbuf[i].data); 1448 kfree(stv680->sbuf[i].data);
1449 } 1449 }
1450 for (i = 0; i < STV680_NUMSCRATCH; i++) 1450 for (i = 0; i < STV680_NUMSCRATCH; i++)
1451 kfree (stv680->scratch[i].data); 1451 kfree(stv680->scratch[i].data);
1452 PDEBUG (0, "STV(i): %s disconnected", stv680->camera_name); 1452 PDEBUG (0, "STV(i): %s disconnected", stv680->camera_name);
1453 1453
1454 /* Free the memory */ 1454 /* Free the memory */
1455 kfree (stv680); 1455 kfree(stv680);
1456} 1456}
1457 1457
1458static void stv680_disconnect (struct usb_interface *intf) 1458static void stv680_disconnect (struct usb_interface *intf)
diff --git a/drivers/video/vgastate.c b/drivers/video/vgastate.c
index 0ea62d8bc703..ca92940f3943 100644
--- a/drivers/video/vgastate.c
+++ b/drivers/video/vgastate.c
@@ -342,16 +342,11 @@ static void vga_cleanup(struct vgastate *state)
342 if (state->vidstate != NULL) { 342 if (state->vidstate != NULL) {
343 struct regstate *saved = (struct regstate *) state->vidstate; 343 struct regstate *saved = (struct regstate *) state->vidstate;
344 344
345 if (saved->vga_font0) 345 vfree(saved->vga_font0);
346 vfree(saved->vga_font0); 346 vfree(saved->vga_font1);
347 if (saved->vga_font1) 347 vfree(saved->vga_text);
348 vfree(saved->vga_font1); 348 vfree(saved->vga_cmap);
349 if (saved->vga_text) 349 vfree(saved->attr);
350 vfree(saved->vga_text);
351 if (saved->vga_cmap)
352 vfree(saved->vga_cmap);
353 if (saved->attr)
354 vfree(saved->attr);
355 kfree(saved); 350 kfree(saved);
356 state->vidstate = NULL; 351 state->vidstate = NULL;
357 } 352 }