lkml.org 
[lkml]   [2000]   [Aug]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] drivers/scsi/eata_dma.c: checking kmallocs
Hi,

Please take a look and consider applying.

- Arnaldo

--- linux-2.4.0-test7-pre5/drivers/scsi/eata_dma.c Mon Jun 19 17:42:40 2000
+++ linux-2.4.0-test7-pre5.acme/drivers/scsi/eata_dma.c Tue Aug 22 08:14:16 2000
@@ -59,6 +59,7 @@
* of bugs during the development. *
************************************************************
* last change: 96/10/21 OS: Linux 2.0.23 *
+ * 00/08/22 OS: Linux 2.4.0-test7-pre5 *
************************************************************/

/* Look in eata_dma.h for configuration and revision information */
@@ -909,8 +910,14 @@

cp = (struct eata_ccb *) kmalloc(sizeof(struct eata_ccb),
GFP_ATOMIC | GFP_DMA);
+ if (!cp)
+ return NULL;
sp = (struct eata_sp *) kmalloc(sizeof(struct eata_sp),
GFP_ATOMIC | GFP_DMA);
+ if (!sp) {
+ kfree(cp);
+ return NULL;
+ }

buff = dma_scratch;

@@ -1445,7 +1452,7 @@
}
}
#endif /* #ifndef CONFIG_PCI */
-}
+ }

int eata_detect(Scsi_Host_Template * tpnt)
{
@@ -1459,10 +1466,15 @@
tpnt->proc_name = "eata_dma";

status = kmalloc(512, GFP_ATOMIC | GFP_DMA);
- dma_scratch = kmalloc(1024, GFP_ATOMIC | GFP_DMA);
+ if (!status) {
+ printk("eata_dma: can't allocate enough memory to probe for hosts!\n");
+ return 0;
+ }

- if(status == NULL || dma_scratch == NULL) {
- printk("eata_dma: can't allocate enough memory to probe for hosts !\n");
+ dma_scratch = kmalloc(1024, GFP_ATOMIC | GFP_DMA);
+ if(!dma_scratch) {
+ printk("eata_dma: can't allocate enough memory to probe for hosts!\n");
+ kfree(status);
return(0);
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 12:37    [W:1.090 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site