public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] add kmalloc check in drviers/pcmcia/rsrc_mgr.c (245-ac16)
@ 2001-06-23 13:22 Rasmus Andersen
  2001-06-23 17:09 ` Eric Lammerts
  0 siblings, 1 reply; 7+ messages in thread
From: Rasmus Andersen @ 2001-06-23 13:22 UTC (permalink / raw)
  To: dhinds; +Cc: linux-kernel

Hi.

The patch below adds a kmalloc check to drivers/pcmcmia/rsrc_mgr.c.
Against 245-ac16 but aplies to 256p6 also. Reported a while back 
by the stanford team.


--- linux-245-ac16-clean/drivers/pcmcia/rsrc_mgr.c	Sat May 19 20:59:21 2001
+++ linux-245-ac16/drivers/pcmcia/rsrc_mgr.c	Sat Jun 23 15:06:54 2001
@@ -189,6 +189,11 @@
     
     /* First, what does a floating port look like? */
     b = kmalloc(256, GFP_KERNEL);
+    if (!b) {
+	printk(" -- aborting.\n");
+	printk(KERN_ERR "Out of memory.");
+	return;
+    }
     memset(b, 0, 256);
     for (i = base, most = 0; i < base+num; i += 8) {
 	if (check_io_resource(i, 8))
-- 
Regards,
        Rasmus(rasmus@jaquet.dk)

"The obvious mathematical breakthrough would be development of an easy way
to factor large prime numbers." 
  -- Bill Gates, The Road Ahead, Viking Penguin (1995)

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

* Re: [PATCH] add kmalloc check in drviers/pcmcia/rsrc_mgr.c (245-ac16)
  2001-06-23 13:22 [PATCH] add kmalloc check in drviers/pcmcia/rsrc_mgr.c (245-ac16) Rasmus Andersen
@ 2001-06-23 17:09 ` Eric Lammerts
  2001-06-23 17:30   ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Lammerts @ 2001-06-23 17:09 UTC (permalink / raw)
  To: Rasmus Andersen; +Cc: linux-kernel


On Sat, 23 Jun 2001, Rasmus Andersen wrote:

> +    if (!b) {
> +	printk(" -- aborting.\n");
> +	printk(KERN_ERR "Out of memory.");
> +	return;
> +    }

Why not printk(KERN_ERR "rsrc_mgr: Out of memory.\n"); ?
Then at least people will know what it was that ran out of memory.

Eric


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

* Re: [PATCH] add kmalloc check in drviers/pcmcia/rsrc_mgr.c (245-ac16)
  2001-06-23 17:09 ` Eric Lammerts
@ 2001-06-23 17:30   ` Arnaldo Carvalho de Melo
  2001-06-24 19:46     ` Rasmus Andersen
  0 siblings, 1 reply; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2001-06-23 17:30 UTC (permalink / raw)
  To: Eric Lammerts; +Cc: Rasmus Andersen, linux-kernel

Em Sat, Jun 23, 2001 at 07:09:37PM +0200, Eric Lammerts escreveu:
> 
> On Sat, 23 Jun 2001, Rasmus Andersen wrote:
> 
> > +    if (!b) {
> > +	printk(" -- aborting.\n");
> > +	printk(KERN_ERR "Out of memory.");
> > +	return;
> > +    }
> 
> Why not printk(KERN_ERR "rsrc_mgr: Out of memory.\n"); ?
> Then at least people will know what it was that ran out of memory.

Better yet:

printk(KERN_ERR __FUNCTION__ "Out of memory.");

Then if you move the code to other function or if you change the name of
the function you don't have to go all over the code doing
s/old_function_name/new_function_name/g

- Arnaldo

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

* Re: [PATCH] add kmalloc check in drviers/pcmcia/rsrc_mgr.c (245-ac16)
  2001-06-23 17:30   ` Arnaldo Carvalho de Melo
@ 2001-06-24 19:46     ` Rasmus Andersen
  2001-06-24 20:52       ` Eric Lammerts
  0 siblings, 1 reply; 7+ messages in thread
From: Rasmus Andersen @ 2001-06-24 19:46 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Eric Lammerts, linux-kernel

On Sat, Jun 23, 2001 at 02:30:06PM -0300, Arnaldo Carvalho de Melo wrote:
[...] 
> printk(KERN_ERR __FUNCTION__ "Out of memory.");
> 
> Then if you move the code to other function or if you change the name of
> the function you don't have to go all over the code doing
> s/old_function_name/new_function_name/g

Excellent suggestion. How about this one:

--- linux-245-ac16-clean/drivers/pcmcia/rsrc_mgr.c      Sat May 19 20:59:21 2001+++ linux-245-ac16/drivers/pcmcia/rsrc_mgr.c    Sat Jun 23 15:06:54 2001
@@ -189,6 +189,11 @@

     /* First, what does a floating port look like? */
     b = kmalloc(256, GFP_KERNEL);
+    if (!b) {
+       printk(" -- aborting.\n");
+       printk(KERN_ERR __FUNCTION__ ": Out of memory.");
+       return;
+    }
     memset(b, 0, 256);
     for (i = base, most = 0; i < base+num; i += 8) {
        if (check_io_resource(i, 8))

-- 
Regards,
        Rasmus(rasmus@jaquet.dk)

You don't become a failure until you're satisfied with being one. 
  -- Anonymous

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

* Re: [PATCH] add kmalloc check in drviers/pcmcia/rsrc_mgr.c (245-ac16)
  2001-06-24 19:46     ` Rasmus Andersen
@ 2001-06-24 20:52       ` Eric Lammerts
  2001-06-24 21:01         ` Rasmus Andersen
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Lammerts @ 2001-06-24 20:52 UTC (permalink / raw)
  To: Rasmus Andersen; +Cc: Arnaldo Carvalho de Melo, linux-kernel


On Sun, 24 Jun 2001, Rasmus Andersen wrote:

> Excellent suggestion. How about this one:

> +    if (!b) {
> +       printk(" -- aborting.\n");
> +       printk(KERN_ERR __FUNCTION__ ": Out of memory.");
> +       return;
> +    }

There are zillions of functions called 'init_module' in the kernel.
I think my suggestion was better (and it had a \n at the end!)

Eric


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

* Re: [PATCH] add kmalloc check in drviers/pcmcia/rsrc_mgr.c (245-ac16)
  2001-06-24 20:52       ` Eric Lammerts
@ 2001-06-24 21:01         ` Rasmus Andersen
  2001-06-24 21:09           ` Eric Lammerts
  0 siblings, 1 reply; 7+ messages in thread
From: Rasmus Andersen @ 2001-06-24 21:01 UTC (permalink / raw)
  To: Eric Lammerts; +Cc: Arnaldo Carvalho de Melo, linux-kernel, dhinds

On Sun, Jun 24, 2001 at 10:52:31PM +0200, Eric Lammerts wrote:
[...] 
> There are zillions of functions called 'init_module' in the kernel.
> I think my suggestion was better (and it had a \n at the end!)

Agreed. Actually, 'ouch' on point two :) BTW, was it intentional
that you dropped the maintainer from the recipient-list back then?

--- linux-245-ac16-clean/drivers/pcmcia/rsrc_mgr.c      Sat May 19 20:59:21 2001+++ linux-245-ac16/drivers/pcmcia/rsrc_mgr.c    Sat Jun 23 15:06:54 2001
@@ -189,6 +189,11 @@
     
     /* First, what does a floating port look like? */
     b = kmalloc(256, GFP_KERNEL);
+    if (!b) {
+       printk(" -- aborting.\n");
+       printk(KERN_ERR "rsrc_mgr: Out of memory.\n");
+       return;
+    }
     memset(b, 0, 256);
     for (i = base, most = 0; i < base+num; i += 8) {
        if (check_io_resource(i, 8))
-- 
Regards,
        Rasmus(rasmus@jaquet.dk)

You know how dumb the average guy is?  Well, by  definition, half
of them are even dumber than that.
            -- J.R. "Bob" Dobbs 

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

* Re: [PATCH] add kmalloc check in drviers/pcmcia/rsrc_mgr.c (245-ac16)
  2001-06-24 21:01         ` Rasmus Andersen
@ 2001-06-24 21:09           ` Eric Lammerts
  0 siblings, 0 replies; 7+ messages in thread
From: Eric Lammerts @ 2001-06-24 21:09 UTC (permalink / raw)
  To: Rasmus Andersen; +Cc: Arnaldo Carvalho de Melo, linux-kernel, dhinds


On Sun, 24 Jun 2001, Rasmus Andersen wrote:
> On Sun, Jun 24, 2001 at 10:52:31PM +0200, Eric Lammerts wrote:
> [...]
> > There are zillions of functions called 'init_module' in the kernel.
> > I think my suggestion was better (and it had a \n at the end!)
>
> Agreed. Actually, 'ouch' on point two :) BTW, was it intentional
> that you dropped the maintainer from the recipient-list back then?

No, sorry.

Eric


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

end of thread, other threads:[~2001-06-24 21:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-06-23 13:22 [PATCH] add kmalloc check in drviers/pcmcia/rsrc_mgr.c (245-ac16) Rasmus Andersen
2001-06-23 17:09 ` Eric Lammerts
2001-06-23 17:30   ` Arnaldo Carvalho de Melo
2001-06-24 19:46     ` Rasmus Andersen
2001-06-24 20:52       ` Eric Lammerts
2001-06-24 21:01         ` Rasmus Andersen
2001-06-24 21:09           ` Eric Lammerts

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox