All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] 2.4.16: kmalloc tidying
@ 2001-12-03 18:37 Ragnar Hojland Espinosa
  2001-12-04  9:33 ` Alan Cox
  0 siblings, 1 reply; 3+ messages in thread
From: Ragnar Hojland Espinosa @ 2001-12-03 18:37 UTC (permalink / raw
  To: linux-kernel

Just please have a look on the binfmt_elf one, which im not absolutely sure
on whether there's nothing else to clean up.

-- 
____/|  Ragnar Højland      Freedom - Linux - OpenGL |    Brainbench MVP
\ o.O|  PGP94C4B2F0D27DE025BE2302C104B78C56 B72F0822 | for Unix Programming
 =(_)=  "Thou shalt not follow the NULL pointer for  | (www.brainbench.com)
   U     chaos and madness await thee at its end."

diff -rup -x '*~' linux-2.4.16-O/drivers/i2c/i2c-proc.c linux-2.4.16/drivers/i2c/i2c-proc.c
--- linux-2.4.16-O/drivers/i2c/i2c-proc.c	Tue Nov 13 05:31:33 2001
+++ linux-2.4.16/drivers/i2c/i2c-proc.c	Mon Dec  3 16:33:55 2001
@@ -119,6 +119,10 @@ int i2c_create_name(char **name, const c
 		sprintf(name_buffer, "%s-i2c-%d-%02x", prefix, id, addr);
 	}
 	*name = kmalloc(strlen(name_buffer) + 1, GFP_KERNEL);
+	if (!*name) {
+		printk (KERN_WARNING "i2c_create_name: not enough memory\n");
+		return -ENOMEM;
+	}
 	strcpy(*name, name_buffer);
 	return 0;
 }
diff -rup -x '*~' linux-2.4.16-O/drivers/net/wireless/airo_cs.c linux-2.4.16/drivers/net/wireless/airo_cs.c
--- linux-2.4.16-O/drivers/net/wireless/airo_cs.c	Tue Nov 13 05:28:44 2001
+++ linux-2.4.16/drivers/net/wireless/airo_cs.c	Mon Dec  3 17:12:32 2001
@@ -244,6 +244,11 @@ static dev_link_t *airo_attach(void)
 	
 	/* Allocate space for private device-specific data */
 	local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
+	if (!local) {
+		printk(KERN_ERR "airo_cs: no memory for new device\n");
+		kfree (link);
+		return NULL;
+	}
 	memset(local, 0, sizeof(local_info_t));
 	link->priv = local;
 	
diff -rup -x '*~' linux-2.4.16-O/drivers/parport/parport_cs.c linux-2.4.16/drivers/parport/parport_cs.c
--- linux-2.4.16-O/drivers/parport/parport_cs.c	Tue Nov 13 05:30:14 2001
+++ linux-2.4.16/drivers/parport/parport_cs.c	Mon Dec  3 16:01:09 2001
@@ -311,6 +311,10 @@ void parport_config(dev_link_t *link)
 #if (LINUX_VERSION_CODE >= VERSION(2,2,8))
     p->private_data = kmalloc(sizeof(struct parport_pc_private),
 			      GFP_KERNEL);
+    if (p->private_data == NULL) {
+        printk(KERN_WARNING "parport_cs: not enough memory\n");
+	goto failed;
+    }
     ((struct parport_pc_private *)(p->private_data))->ctr = 0x0c;
 #endif
     parport_proc_register(p);
diff -rup -x '*~' linux-2.4.16-O/drivers/sbus/char/envctrl.c linux-2.4.16/drivers/sbus/char/envctrl.c
--- linux-2.4.16-O/drivers/sbus/char/envctrl.c	Mon Dec  3 17:17:13 2001
+++ linux-2.4.16/drivers/sbus/char/envctrl.c	Tue Nov 13 05:31:02 2001
@@ -897,10 +897,6 @@ static void envctrl_init_i2c_child(struc
 		}
 
                 pchild->tables = kmalloc(tbls_size, GFP_KERNEL);
-		if (!pchild->tables) {
-			printk("envctrl: Failed to get table, not enough memory.\n");
-			return;
-		}
                 len = prom_getproperty(node, "tables",
 				       (char *) pchild->tables, tbls_size);
                 if (len <= 0) {
diff -rup -x '*~' linux-2.4.16-O/drivers/sbus/dvma.c linux-2.4.16/drivers/sbus/dvma.c
--- linux-2.4.16-O/drivers/sbus/dvma.c	Thu Feb 22 13:40:13 2001
+++ linux-2.4.16/drivers/sbus/dvma.c	Mon Dec  3 16:26:05 2001
@@ -90,7 +90,10 @@ void __init dvma_init(struct sbus_bus *s
 
 		/* Found one... */
 		dma = kmalloc(sizeof(struct sbus_dma), GFP_ATOMIC);
-
+		if (!dma) {
+			printk (KERN_WARNING "dvma_init: not enough memory\n");
+			return;
+		}
 		dma->sdev = this_dev;
 
 		/* Put at end of dma chain */
@@ -126,7 +129,12 @@ void __init sun4_dvma_init(void)
 
 	if(sun4_dma_physaddr) {
 		dma = kmalloc(sizeof(struct sbus_dma), GFP_ATOMIC);
-
+		if (!dma) {
+			printk (KERN_WARNING "sun4_dvma_init: not enough memory\n");
+			dma_chain = NULL;
+			return;
+		}
+		
 		/* No SBUS */
 		dma->sdev = NULL;
 
diff -rup -x '*~' linux-2.4.16-O/drivers/sound/btaudio.c linux-2.4.16/drivers/sound/btaudio.c
--- linux-2.4.16-O/drivers/sound/btaudio.c	Tue Nov 13 05:31:48 2001
+++ linux-2.4.16/drivers/sound/btaudio.c	Mon Dec  3 16:09:27 2001
@@ -885,6 +885,12 @@ static int __devinit btaudio_probe(struc
 	}
 
 	bta = kmalloc(sizeof(*bta),GFP_ATOMIC);
+	if (!bta) {
+		printk(KERN_WARNING 
+		       "btaudio: not enough memory\n");
+		rc = -ENOMEM;
+		goto fail1;
+	}
 	memset(bta,0,sizeof(*bta));
 
 	bta->pci  = pci_dev;
diff -rup -x '*~' linux-2.4.16-O/fs/binfmt_elf.c linux-2.4.16/fs/binfmt_elf.c
--- linux-2.4.16-O/fs/binfmt_elf.c	Tue Nov 13 05:31:51 2001
+++ linux-2.4.16/fs/binfmt_elf.c	Mon Dec  3 17:05:53 2001
@@ -609,7 +609,9 @@ static int load_elf_binary(struct linux_
 	/* Do this so that we can load the interpreter, if need be.  We will
 	   change some of these later */
 	current->mm->rss = 0;
-	setup_arg_pages(bprm); /* XXX: check error */
+	retval = setup_arg_pages(bprm);
+	if (retval) 
+		goto out_free_dentry;
 	current->mm->start_stack = bprm->p;
 
 	/* Now we do a little grungy work by mmaping the ELF image into
diff -rup -x '*~' linux-2.4.16-O/fs/qnx4/inode.c linux-2.4.16/fs/qnx4/inode.c
--- linux-2.4.16-O/fs/qnx4/inode.c	Tue Nov 13 05:30:44 2001
+++ linux-2.4.16/fs/qnx4/inode.c	Mon Dec  3 14:37:14 2001
@@ -318,6 +318,10 @@ static const char *qnx4_checkroot(struct
 					if (!strncmp(rootdir->di_fname, QNX4_BMNAME, sizeof QNX4_BMNAME)) {
 						found = 1;
 						sb->u.qnx4_sb.BitMap = kmalloc( sizeof( struct qnx4_inode_entry ), GFP_KERNEL );
+						if (!sb->u.qnx4_sb.BitMap) {
+							brelse (bh);
+							return "not enough memory for bitmap inode";
+						}
 						memcpy( sb->u.qnx4_sb.BitMap, rootdir, sizeof( struct qnx4_inode_entry ) );	/* keep bitmap inode known */
 						break;
 					}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] 2.4.16: kmalloc tidying
  2001-12-04  9:33 ` Alan Cox
@ 2001-12-03 23:02   ` Ragnar Hojland Espinosa
  0 siblings, 0 replies; 3+ messages in thread
From: Ragnar Hojland Espinosa @ 2001-12-03 23:02 UTC (permalink / raw
  To: Alan Cox; +Cc: linux-kernel

On Tue, Dec 04, 2001 at 09:33:46AM +0000, Alan Cox wrote:
> > +++ linux-2.4.16/drivers/sbus/char/envctrl.c	Tue Nov 13 05:31:02 2001
> > @@ -897,10 +897,6 @@ static void envctrl_init_i2c_child(struc
> >  		}
> > =20
> >                  pchild->tables =3D kmalloc(tbls_size, GFP_KERNEL);
> > -		if (!pchild->tables) {
> > -			printk("envctrl: Failed to get table, not enough memory.\n");
> 
> Why are you removing the checks here ?

Hrmpf.. reversed patch, I was actually adding them.

> >  	current->mm->rss =3D 0;
> > -	setup_arg_pages(bprm); /* XXX: check error */
> > +	retval =3D setup_arg_pages(bprm);
> > +	if (retval)=20
> > +		goto out_free_dentry;
> 
> At this point you need to do more drastic things - see the last -ac patch
> for a possible solution

That does sound entertaining.. :)

-- 
____/|  Ragnar Højland      Freedom - Linux - OpenGL |    Brainbench MVP
\ o.O|  PGP94C4B2F0D27DE025BE2302C104B78C56 B72F0822 | for Unix Programming
 =(_)=  "Thou shalt not follow the NULL pointer for  | (www.brainbench.com)
   U     chaos and madness await thee at its end."

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] 2.4.16: kmalloc tidying
  2001-12-03 18:37 [PATCH] 2.4.16: kmalloc tidying Ragnar Hojland Espinosa
@ 2001-12-04  9:33 ` Alan Cox
  2001-12-03 23:02   ` Ragnar Hojland Espinosa
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Cox @ 2001-12-04  9:33 UTC (permalink / raw
  To: Ragnar Hojland Espinosa; +Cc: linux-kernel

> +++ linux-2.4.16/drivers/sbus/char/envctrl.c	Tue Nov 13 05:31:02 2001
> @@ -897,10 +897,6 @@ static void envctrl_init_i2c_child(struc
>  		}
> =20
>                  pchild->tables =3D kmalloc(tbls_size, GFP_KERNEL);
> -		if (!pchild->tables) {
> -			printk("envctrl: Failed to get table, not enough memory.\n");

Why are you removing the checks here ?

>  	current->mm->rss =3D 0;
> -	setup_arg_pages(bprm); /* XXX: check error */
> +	retval =3D setup_arg_pages(bprm);
> +	if (retval)=20
> +		goto out_free_dentry;

At this point you need to do more drastic things - see the last -ac patch
for a possible solution

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-12-05  0:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-12-03 18:37 [PATCH] 2.4.16: kmalloc tidying Ragnar Hojland Espinosa
2001-12-04  9:33 ` Alan Cox
2001-12-03 23:02   ` Ragnar Hojland Espinosa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.