patch-2.4.0-test11 linux/drivers/scsi/scsi_debug.c

Next file: linux/drivers/scsi/scsi_error.c
Previous file: linux/drivers/scsi/psi240i.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test10/linux/drivers/scsi/scsi_debug.c linux/drivers/scsi/scsi_debug.c
@@ -554,9 +554,21 @@
         
         printk("Allocating host dev\n");
         sdev = scsi_get_host_dev(shpnt);
+        if(sdev==NULL)
+        {
+        	printk("Out of memory.\n");
+        	return;
+        }
+        
         printk("Got %p. Allocating command block\n", sdev);
         scp  = scsi_allocate_request(sdev);
         printk("Got %p\n", scp);
+        
+        if(scp==NULL)
+        {
+        	printk("Out of memory.\n");
+        	goto bail;
+        }
 
         scp->sr_cmd_len = 6;
         scp->sr_use_sg = 0;
@@ -567,7 +579,8 @@
         
         printk("Releasing command\n");
         scsi_release_request(scp);
-        printk("Freeing device\n");
+bail:
+	printk("Freeing device\n");
         scsi_free_host_dev(sdev);
 }
 
@@ -762,6 +775,8 @@
 	static Scsi_Host_Template driver_copy = SCSI_DEBUG;
 	void *rtn;
 	rtn = kmalloc(sizeof(driver_copy), GFP_ATOMIC);
+	if(rtn==NULL)
+		return NULL;
 	memcpy(rtn, (void *) &driver_copy, sizeof(driver_copy));
 	return rtn;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)