[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 <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
Jesper Juhl 2005-09-10 00:26:54 -07:00 • committed by Linus Torvalds
commit f9101210e7
20 changed files with 86 additions and 142 deletions

View file

@ -168,10 +168,8 @@ void saa7146_pgtable_free(struct pci_dev *pci, struct saa7146_pgtable *pt)
return;
pci_free_consistent(pci, pt->size, pt->cpu, pt->dma);
pt->cpu = NULL;
if (NULL != pt->slist) {
kfree(pt->slist);
pt->slist = NULL;
}
kfree(pt->slist);
pt->slist = NULL;
}
int saa7146_pgtable_alloc(struct pci_dev *pci, struct saa7146_pgtable *pt)

View file

@ -445,10 +445,8 @@ static void cpia_usb_free_resources(struct usb_cpia *ucpia, int try)
ucpia->sbuf[1].urb = NULL;
}
if (ucpia->sbuf[1].data) {
kfree(ucpia->sbuf[1].data);
ucpia->sbuf[1].data = NULL;
}
kfree(ucpia->sbuf[1].data);
ucpia->sbuf[1].data = NULL;
if (ucpia->sbuf[0].urb) {
usb_kill_urb(ucpia->sbuf[0].urb);
@ -456,10 +454,8 @@ static void cpia_usb_free_resources(struct usb_cpia *ucpia, int try)
ucpia->sbuf[0].urb = NULL;
}
if (ucpia->sbuf[0].data) {
kfree(ucpia->sbuf[0].data);
ucpia->sbuf[0].data = NULL;
}
kfree(ucpia->sbuf[0].data);
ucpia->sbuf[0].data = NULL;
}
static int cpia_usb_close(void *privdata)
@ -623,20 +619,14 @@ static void cpia_disconnect(struct usb_interface *intf)
ucpia->curbuff = ucpia->workbuff = NULL;
if (ucpia->buffers[2]) {
vfree(ucpia->buffers[2]);
ucpia->buffers[2] = NULL;
}
vfree(ucpia->buffers[2]);
ucpia->buffers[2] = NULL;
if (ucpia->buffers[1]) {
vfree(ucpia->buffers[1]);
ucpia->buffers[1] = NULL;
}
vfree(ucpia->buffers[1]);
ucpia->buffers[1] = NULL;
if (ucpia->buffers[0]) {
vfree(ucpia->buffers[0]);
ucpia->buffers[0] = NULL;
}
vfree(ucpia->buffers[0]);
ucpia->buffers[0] = NULL;
cam->lowlevel_data = NULL;
kfree(ucpia);

View file

@ -2184,30 +2184,18 @@ static void release_saa(void)
vfree(saa->vidbuf);
vfree(saa->audbuf);
vfree(saa->osdbuf);
if (saa->dmavid2)
kfree((void *) saa->dmavid2);
kfree(saa->dmavid2);
saa->audbuf = saa->vidbuf = saa->osdbuf = NULL;
saa->dmavid2 = NULL;
if (saa->dmadebi)
kfree((void *) saa->dmadebi);
if (saa->dmavid1)
kfree((void *) saa->dmavid1);
if (saa->dmavid2)
kfree((void *) saa->dmavid2);
if (saa->dmavid3)
kfree((void *) saa->dmavid3);
if (saa->dmaa1in)
kfree((void *) saa->dmaa1in);
if (saa->dmaa1out)
kfree((void *) saa->dmaa1out);
if (saa->dmaa2in)
kfree((void *) saa->dmaa2in);
if (saa->dmaa2out)
kfree((void *) saa->dmaa2out);
if (saa->dmaRPS1)
kfree((void *) saa->dmaRPS1);
if (saa->dmaRPS2)
kfree((void *) saa->dmaRPS2);
kfree(saa->dmadebi);
kfree(saa->dmavid1);
kfree(saa->dmavid3);
kfree(saa->dmaa1in);
kfree(saa->dmaa1out);
kfree(saa->dmaa2in);
kfree(saa->dmaa2out);
kfree(saa->dmaRPS1);
kfree(saa->dmaRPS2);
free_irq(saa->irq, saa);
if (saa->saa7146_mem)
iounmap(saa->saa7146_mem);

View file

@ -267,10 +267,10 @@ int videobuf_dma_free(struct videobuf_dmabuf *dma)
kfree(dma->pages);
dma->pages = NULL;
}
if (dma->vmalloc) {
vfree(dma->vmalloc);
dma->vmalloc = NULL;
}
vfree(dma->vmalloc);
dma->vmalloc = NULL;
if (dma->bus_addr) {
dma->bus_addr = 0;
}

View file

@ -650,7 +650,7 @@ jpg_fbuffer_free (struct file *file)
off += PAGE_SIZE)
ClearPageReserved(MAP_NR
(mem + off));
kfree((void *) mem);
kfree(mem);
fh->jpg_buffers.buffer[i].frag_tab[0] = 0;
fh->jpg_buffers.buffer[i].frag_tab[1] = 0;
}

View file

@ -820,11 +820,9 @@ void zoran_close(struct video_device* dev)
msleep(100); /* Wait 1/10th of a second */
/* free the allocated framebuffer */
if (ztv->fbuffer)
bfree( ztv->fbuffer, ZORAN_MAX_FBUFSIZE );
bfree(ztv->fbuffer, ZORAN_MAX_FBUFSIZE);
ztv->fbuffer = 0;
if (ztv->overinfo.overlay)
kfree( ztv->overinfo.overlay );
kfree(ztv->overinfo.overlay);
ztv->overinfo.overlay = 0;
}