All of lore.kernel.org
 help / color / mirror / Atom feed
* [KJ]  [PATCH] Check kmalloc() return value
@ 2006-09-28  7:58 Galya Tcharny
  2006-09-28  9:18 ` Galya Tcharny
  2006-09-28 12:58 ` Galya Tcharny
  0 siblings, 2 replies; 7+ messages in thread
From: Galya Tcharny @ 2006-09-28  7:58 UTC (permalink / raw)
  To: kernel-janitors

Added checks for kmalloc() return value.

Signed-off-by: Galya Tcharny <gtcharny@gmail.com>

 drivers/net/au1000_eth.c |    3 +++
 drivers/net/s2io.c       |    3 +++
 2 files changed, 6 insertions(+)

diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
linux-2.6.18-orig/drivers/net/au1000_eth.c
linux-2.6.18/drivers/net/au1000_eth.c
--- linux-2.6.18-orig/drivers/net/au1000_eth.c 2006-09-27
14:51:31.000000000 +0300
+++ linux-2.6.18/drivers/net/au1000_eth.c 2006-09-28 09:24:11.000000000 +0300
@@ -717,6 +717,9 @@ static struct net_device * au1000_probe(
  aup->mii_bus.name = "au1000_eth_mii";
  aup->mii_bus.id = aup->mac_id;
  aup->mii_bus.irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
+ if(aup->mii_bus.irq = NULL) {
+  goto err_out;
+ }
  for(i = 0; i < PHY_MAX_ADDR; ++i)
   aup->mii_bus.irq[i] = PHY_POLL;

diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
linux-2.6.18-orig/drivers/net/s2io.c linux-2.6.18/drivers/net/s2io.c
--- linux-2.6.18-orig/drivers/net/s2io.c 2006-09-27 14:51:33.000000000 +0300
+++ linux-2.6.18/drivers/net/s2io.c 2006-09-28 09:26:32.000000000 +0300
@@ -624,6 +624,9 @@ static int init_shared_mem(struct s2io_n
    rx_blocks->rxds = kmalloc(sizeof(rxd_info_t)*
         rxd_count[nic->rxd_mode],
         GFP_KERNEL);
+   if(rx_blocks->rxds = NULL) {
+    return -ENOMEM;
+   }
    for (l=0; l<rxd_count[nic->rxd_mode];l++) {
     rx_blocks->rxds[l].virt_addr       rx_blocks->block_virt_addr +
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* [KJ]  [PATCH] Check kmalloc() return value
  2006-09-28  7:58 [KJ] [PATCH] Check kmalloc() return value Galya Tcharny
@ 2006-09-28  9:18 ` Galya Tcharny
  2006-09-28 12:58 ` Galya Tcharny
  1 sibling, 0 replies; 7+ messages in thread
From: Galya Tcharny @ 2006-09-28  9:18 UTC (permalink / raw)
  To: kernel-janitors

On 9/28/06, Jesper Juhl <jesper.juhl@gmail.com> wrote:
> On 28/09/06, Galya Tcharny <gtcharny@gmail.com> wrote:
> > Added checks for kmalloc() return value.
> >
> The patch also seems to be whitespace damaged somehow. Your lines are
> not properly indented - at least not the copy my mail client gives me.
>

Thanks for your suggestions. Please find below fixed version.

 drivers/net/au1000_eth.c |    5 ++++-
 drivers/net/s2io.c       |    3 +++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
linux-2.6.18-orig/drivers/net/au1000_eth.c
linux-2.6.18/drivers/net/au1000_eth.c
--- linux-2.6.18-orig/drivers/net/au1000_eth.c	2006-09-27
14:51:31.000000000 +0300
+++ linux-2.6.18/drivers/net/au1000_eth.c	2006-09-28 12:10:30.000000000 +0300
@@ -717,7 +717,10 @@ static struct net_device * au1000_probe(
 	aup->mii_bus.name = "au1000_eth_mii";
 	aup->mii_bus.id = aup->mac_id;
 	aup->mii_bus.irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
-	for(i = 0; i < PHY_MAX_ADDR; ++i)
+	if (aup->mii_bus.irq = NULL) {
+		goto err_out;
+	}
+	for (i = 0; i < PHY_MAX_ADDR; ++i)
 		aup->mii_bus.irq[i] = PHY_POLL;

 	/* if known, set corresponding PHY IRQs */
diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
linux-2.6.18-orig/drivers/net/s2io.c linux-2.6.18/drivers/net/s2io.c
--- linux-2.6.18-orig/drivers/net/s2io.c	2006-09-27 14:51:33.000000000 +0300
+++ linux-2.6.18/drivers/net/s2io.c	2006-09-28 12:07:54.000000000 +0300
@@ -624,6 +624,9 @@ static int init_shared_mem(struct s2io_n
 			rx_blocks->rxds = kmalloc(sizeof(rxd_info_t)*
 						  rxd_count[nic->rxd_mode],
 						  GFP_KERNEL);
+			if (rx_blocks->rxds = NULL) {
+				return -ENOMEM;
+			}
 			for (l=0; l<rxd_count[nic->rxd_mode];l++) {
 				rx_blocks->rxds[l].virt_addr  					rx_blocks->block_virt_addr +
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* [KJ]  [PATCH] Check kmalloc() return value
  2006-09-28  7:58 [KJ] [PATCH] Check kmalloc() return value Galya Tcharny
  2006-09-28  9:18 ` Galya Tcharny
@ 2006-09-28 12:58 ` Galya Tcharny
  1 sibling, 0 replies; 7+ messages in thread
From: Galya Tcharny @ 2006-09-28 12:58 UTC (permalink / raw)
  To: kernel-janitors


[-- Attachment #1.1: Type: text/plain, Size: 2028 bytes --]

On 9/28/06, Jesper Juhl <jesper.juhl@gmail.com> wrote:

>Your mail client still mangles the patch. The two lines above should
>have been one line. Tell your mailer not to wordwrap lines.
>

Hope I got it right this time.

Thanks,

Galya


drivers/net/au1000_eth.c |    5 ++++-
drivers/net/s2io.c       |    3 +++
2 files changed, 7 insertions(+), 1 deletion(-)


diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
linux-2.6.18-orig/drivers/net/au1000_eth.c
linux-2.6.18/drivers/net/au1000_eth.c
--- linux-2.6.18-orig/drivers/net/au1000_eth.c  2006-09-27 14:51:
31.000000000 +0300
+++ linux-2.6.18/drivers/net/au1000_eth.c       2006-09-28 12:10:
30.000000000 +0300
@@ -717,7 +717,10 @@ static struct net_device * au1000_probe(
       aup->mii_bus.name = "au1000_eth_mii";
       aup->mii_bus.id = aup->mac_id;
       aup->mii_bus.irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
-       for(i = 0; i < PHY_MAX_ADDR; ++i)
+       if (aup->mii_bus.irq == NULL) {
+               goto err_out;
+       }
+       for (i = 0; i < PHY_MAX_ADDR; ++i)
               aup->mii_bus.irq[i] = PHY_POLL;

       /* if known, set corresponding PHY IRQs */
diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
linux-2.6.18-orig/drivers/net/s2io.c
linux-2.6.18/drivers/net/s2io.c
--- linux-2.6.18-orig/drivers/net/s2io.c        2006-09-27 14:51:
33.000000000 +0300
+++ linux-2.6.18/drivers/net/s2io.c     2006-09-28 12:07:54.000000000 +0300
@@ -624,6 +624,9 @@ static int init_shared_mem(struct s2io_n
                       rx_blocks->rxds = kmalloc(sizeof(rxd_info_t)*
                                                 rxd_count[nic->rxd_mode],
                                                 GFP_KERNEL);
+                       if (rx_blocks->rxds == NULL) {
+                               return -ENOMEM;
+                       }
                       for (l=0; l<rxd_count[nic->rxd_mode];l++) {
                               rx_blocks->rxds[l].virt_addr =
                                       rx_blocks->block_virt_addr +

[-- Attachment #1.2: Type: text/html, Size: 4323 bytes --]

[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* Re: [KJ] [PATCH] Check kmalloc() return value
  2006-09-28  8:41 Jesper Juhl
  2006-09-28  9:28 ` Jesper Juhl
  2006-09-28 15:37 ` Randy Dunlap
@ 2006-10-04  2:15 ` Randy Dunlap
  2 siblings, 0 replies; 7+ messages in thread
From: Randy Dunlap @ 2006-10-04  2:15 UTC (permalink / raw)
  To: kernel-janitors

On Thu, 28 Sep 2006 12:18:35 +0300 Galya Tcharny wrote:

> On 9/28/06, Jesper Juhl <jesper.juhl@gmail.com> wrote:
> > On 28/09/06, Galya Tcharny <gtcharny@gmail.com> wrote:
> > > Added checks for kmalloc() return value.
> > >
> > The patch also seems to be whitespace damaged somehow. Your lines are
> > not properly indented - at least not the copy my mail client gives me.
> >
> 
> Thanks for your suggestions. Please find below fixed version.
> 
>  drivers/net/au1000_eth.c |    5 ++++-
>  drivers/net/s2io.c       |    3 +++
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
> linux-2.6.18-orig/drivers/net/au1000_eth.c
> linux-2.6.18/drivers/net/au1000_eth.c
> --- linux-2.6.18-orig/drivers/net/au1000_eth.c	2006-09-27
> 14:51:31.000000000 +0300
> +++ linux-2.6.18/drivers/net/au1000_eth.c	2006-09-28 12:10:30.000000000 +0300
> @@ -717,7 +717,10 @@ static struct net_device * au1000_probe(
>  	aup->mii_bus.name = "au1000_eth_mii";
>  	aup->mii_bus.id = aup->mac_id;
>  	aup->mii_bus.irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
> -	for(i = 0; i < PHY_MAX_ADDR; ++i)
> +	if (aup->mii_bus.irq = NULL) {
> +		goto err_out;
> +	}
> +	for (i = 0; i < PHY_MAX_ADDR; ++i)
>  		aup->mii_bus.irq[i] = PHY_POLL;
> 
>  	/* if known, set corresponding PHY IRQs */
> diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
> linux-2.6.18-orig/drivers/net/s2io.c linux-2.6.18/drivers/net/s2io.c
> --- linux-2.6.18-orig/drivers/net/s2io.c	2006-09-27 14:51:33.000000000 +0300
> +++ linux-2.6.18/drivers/net/s2io.c	2006-09-28 12:07:54.000000000 +0300
> @@ -624,6 +624,9 @@ static int init_shared_mem(struct s2io_n
>  			rx_blocks->rxds = kmalloc(sizeof(rxd_info_t)*
>  						  rxd_count[nic->rxd_mode],
>  						  GFP_KERNEL);
> +			if (rx_blocks->rxds = NULL) {
> +				return -ENOMEM;
> +			}
>  			for (l=0; l<rxd_count[nic->rxd_mode];l++) {
>  				rx_blocks->rxds[l].virt_addr >  					rx_blocks->block_virt_addr +

Along with Jesper's comments, kernel style is only to use
braces around an if-block when the block is more than one
statement long -- not used when it's only one statement.

Hm, maybe we need to add that to Documentation/CodingStyle.

---
~Randy
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* Re: [KJ] [PATCH] Check kmalloc() return value
  2006-09-28  8:41 Jesper Juhl
  2006-09-28  9:28 ` Jesper Juhl
@ 2006-09-28 15:37 ` Randy Dunlap
  2006-10-04  2:15 ` Randy Dunlap
  2 siblings, 0 replies; 7+ messages in thread
From: Randy Dunlap @ 2006-09-28 15:37 UTC (permalink / raw)
  To: kernel-janitors

On Thu, 28 Sep 2006 15:58:33 +0300 Galya Tcharny wrote:

> On 9/28/06, Jesper Juhl <jesper.juhl@gmail.com> wrote:
> 
> >Your mail client still mangles the patch. The two lines above should
> >have been one line. Tell your mailer not to wordwrap lines.
> >
> 
> Hope I got it right this time.

The good news is that the patch applies if 'patch -l' is used
(ignore whitespace).  Without -l, I get:

patching file drivers/net/au1000_eth.c
Hunk #1 FAILED at 717.
1 out of 1 hunk FAILED -- saving rejects to file drivers/net/au1000_eth.c.rej
patching file drivers/net/s2io.c
Hunk #1 FAILED at 624.
1 out of 1 hunk FAILED -- saving rejects to file drivers/net/s2io.c.rej

You should pull the email from the mailing list and try to apply it.
And then send it to yourself and apply it until it will apply cleanly
(without using the -l option).


> drivers/net/au1000_eth.c |    5 ++++-
> drivers/net/s2io.c       |    3 +++
> 2 files changed, 7 insertions(+), 1 deletion(-)
> 
> 
> diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
> linux-2.6.18-orig/drivers/net/au1000_eth.c
> linux-2.6.18/drivers/net/au1000_eth.c
> --- linux-2.6.18-orig/drivers/net/au1000_eth.c  2006-09-27 14:51:
> 31.000000000 +0300
> +++ linux-2.6.18/drivers/net/au1000_eth.c       2006-09-28 12:10:
> 30.000000000 +0300
> @@ -717,7 +717,10 @@ static struct net_device * au1000_probe(
>        aup->mii_bus.name = "au1000_eth_mii";
>        aup->mii_bus.id = aup->mac_id;
>        aup->mii_bus.irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
> -       for(i = 0; i < PHY_MAX_ADDR; ++i)
> +       if (aup->mii_bus.irq = NULL) {
> +               goto err_out;
> +       }

Your email client (or are you using copy-and-paste? that usually
also has problems) is munging tabs into spaces.  Not good.

Also, don't use braces around 1-line "blocks."  See
Documentation/CodingStyle in the kernel source tree.

> +       for (i = 0; i < PHY_MAX_ADDR; ++i)
>                aup->mii_bus.irq[i] = PHY_POLL;
> 
>        /* if known, set corresponding PHY IRQs */
> diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
> linux-2.6.18-orig/drivers/net/s2io.c
> linux-2.6.18/drivers/net/s2io.c
> --- linux-2.6.18-orig/drivers/net/s2io.c        2006-09-27 14:51:
> 33.000000000 +0300
> +++ linux-2.6.18/drivers/net/s2io.c     2006-09-28 12:07:54.000000000 +0300
> @@ -624,6 +624,9 @@ static int init_shared_mem(struct s2io_n
>                        rx_blocks->rxds = kmalloc(sizeof(rxd_info_t)*
>                                                  rxd_count[nic->rxd_mode],
>                                                  GFP_KERNEL);
> +                       if (rx_blocks->rxds = NULL) {
> +                               return -ENOMEM;
> +                       }

No braces.
>                        for (l=0; l<rxd_count[nic->rxd_mode];l++) {
>                                rx_blocks->rxds[l].virt_addr >                                        rx_blocks->block_virt_addr +
> 


---
~Randy
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* Re: [KJ] [PATCH] Check kmalloc() return value
  2006-09-28  8:41 Jesper Juhl
@ 2006-09-28  9:28 ` Jesper Juhl
  2006-09-28 15:37 ` Randy Dunlap
  2006-10-04  2:15 ` Randy Dunlap
  2 siblings, 0 replies; 7+ messages in thread
From: Jesper Juhl @ 2006-09-28  9:28 UTC (permalink / raw)
  To: kernel-janitors

On 28/09/06, Galya Tcharny <gtcharny@gmail.com> wrote:
> On 9/28/06, Jesper Juhl <jesper.juhl@gmail.com> wrote:
> > On 28/09/06, Galya Tcharny <gtcharny@gmail.com> wrote:
> > > Added checks for kmalloc() return value.
> > >
> > The patch also seems to be whitespace damaged somehow. Your lines are
> > not properly indented - at least not the copy my mail client gives me.
> >
>
> Thanks for your suggestions. Please find below fixed version.
> [snip]

> --- linux-2.6.18-orig/drivers/net/au1000_eth.c  2006-09-27
> 14:51:31.000000000 +0300

Your mail client still mangles the patch. The two lines above should
have been one line. Tell your mailer not to wordwrap lines.


-- 
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* Re: [KJ] [PATCH] Check kmalloc() return value
@ 2006-09-28  8:41 Jesper Juhl
  2006-09-28  9:28 ` Jesper Juhl
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jesper Juhl @ 2006-09-28  8:41 UTC (permalink / raw)
  To: kernel-janitors

On 28/09/06, Galya Tcharny <gtcharny@gmail.com> wrote:
> Added checks for kmalloc() return value.
>
> Signed-off-by: Galya Tcharny <gtcharny@gmail.com>
>
>  drivers/net/au1000_eth.c |    3 +++
>  drivers/net/s2io.c       |    3 +++
>  2 files changed, 6 insertions(+)
>
> diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
> linux-2.6.18-orig/drivers/net/au1000_eth.c
> linux-2.6.18/drivers/net/au1000_eth.c
> --- linux-2.6.18-orig/drivers/net/au1000_eth.c 2006-09-27
> 14:51:31.000000000 +0300
> +++ linux-2.6.18/drivers/net/au1000_eth.c 2006-09-28 09:24:11.000000000 +0300
> @@ -717,6 +717,9 @@ static struct net_device * au1000_probe(
>   aup->mii_bus.name = "au1000_eth_mii";
>   aup->mii_bus.id = aup->mac_id;
>   aup->mii_bus.irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
> + if(aup->mii_bus.irq = NULL) {

Missing space after "if":
   if (aup->mii_bus.irq = NULL) {


> +  goto err_out;
> + }
>   for(i = 0; i < PHY_MAX_ADDR; ++i)

While you are there you might consider adding the missing space in
that "for" loop as well :
   for (i = 0; i < PHY_MAX_ADDR; ++i)



>    aup->mii_bus.irq[i] = PHY_POLL;
>
> diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
> linux-2.6.18-orig/drivers/net/s2io.c linux-2.6.18/drivers/net/s2io.c
> --- linux-2.6.18-orig/drivers/net/s2io.c 2006-09-27 14:51:33.000000000 +0300
> +++ linux-2.6.18/drivers/net/s2io.c 2006-09-28 09:26:32.000000000 +0300
> @@ -624,6 +624,9 @@ static int init_shared_mem(struct s2io_n
>     rx_blocks->rxds = kmalloc(sizeof(rxd_info_t)*
>          rxd_count[nic->rxd_mode],
>          GFP_KERNEL);
> +   if(rx_blocks->rxds = NULL) {

Missing space :
   if (rx_blocks->rxds = NULL) {

> +    return -ENOMEM;
> +   }
>     for (l=0; l<rxd_count[nic->rxd_mode];l++) {
>      rx_blocks->rxds[l].virt_addr >       rx_blocks->block_virt_addr +


The patch also seems to be whitespace damaged somehow. Your lines are
not properly indented - at least not the copy my mail client gives me.

-- 
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

end of thread, other threads:[~2006-10-04  2:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-28  7:58 [KJ] [PATCH] Check kmalloc() return value Galya Tcharny
2006-09-28  9:18 ` Galya Tcharny
2006-09-28 12:58 ` Galya Tcharny
2006-09-28  8:41 Jesper Juhl
2006-09-28  9:28 ` Jesper Juhl
2006-09-28 15:37 ` Randy Dunlap
2006-10-04  2:15 ` Randy Dunlap

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.