Skip to contentSkip to conversation

check dev_alloc_skb() return value in s2io.c

PATCH New Eric Sesterhenn 1 participant 1 message Sep 28, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 check dev_alloc_skb() return value in s2io.c

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.

drivers/net/s2io.c renamed from drivers/net/s2io.c.orig +11 -0
@@ -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,