netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Sesterhenn <snakebyte@gmx.de>
To: netdev@vger.kernel.org
Subject: [Patch] check dev_alloc_skb() return value in s2io.c
Date: Thu, 28 Sep 2006 15:16:26 +0200	[thread overview]
Message-ID: <1159449386.8136.6.camel@alice> (raw)

hi,

coverity spotted two dev_alloc_skb() calls,
where we use the return value without checking it
for NULL. This patch simply adds the check, including
the debug message that is used in all other dev_alloc_skb()
calls.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.18-git8/drivers/net/s2io.c.orig	2006-09-28 01:25:36.000000000 +0200
+++ linux-2.6.18-git8/drivers/net/s2io.c	2006-09-28 01:26:32.000000000 +0200
@@ -5989,6 +5989,12 @@ static int set_rxd_buffer_pointer(nic_t 
 			((RxD3_t*)rxdp)->Buffer1_ptr = *temp1;
 		} else {
 			*skb = dev_alloc_skb(size);
+			if (!*skb) {
+				DBG_PRINT(ERR_DBG, "%s: dev_alloc_skb \
+					failed\n ", dev->name);
+					return -ENOMEM;
+			}
+
 			((RxD3_t*)rxdp)->Buffer2_ptr = *temp2 =
 				pci_map_single(sp->pdev, (*skb)->data,
 					       dev->mtu + 4,
@@ -6011,6 +6017,11 @@ static int set_rxd_buffer_pointer(nic_t 
 			((RxD3_t*)rxdp)->Buffer2_ptr = *temp2;
 		} else {
 			*skb = dev_alloc_skb(size);
+			if (!*skb) {
+				DBG_PRINT(ERR_DBG, "%s: dev_alloc_skb \
+					failed\n ", dev->name);
+				return -ENOMEM;
+			}
 
 			((RxD3_t*)rxdp)->Buffer0_ptr = *temp0 =
 				pci_map_single(sp->pdev, ba->ba_0, BUF0_LEN,



                 reply	other threads:[~2006-09-28 13:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1159449386.8136.6.camel@alice \
    --to=snakebyte@gmx.de \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).