提交 2ceaac75 编写于 作者: D David Rientjes 提交者: Jeff Garzik

[PATCH] net s2io: return on NULL dev_alloc_skb()

Checks for NULL dev_alloc_skb() and returns on true to avoid subsequent
dereference.

Cc: Jeff Garzik <jgarzik@pobox.com>
Cc: Christoph Hellwig <hch@infrared.org>
Signed-off-by: NDavid Rientjes <rientjes@cs.washington.edu>
Signed-off-by: NJeff Garzik <jeff@garzik.org>
上级 1e1675cc
...@@ -5985,6 +5985,11 @@ static int set_rxd_buffer_pointer(nic_t *sp, RxD_t *rxdp, buffAdd_t *ba, ...@@ -5985,6 +5985,11 @@ static int set_rxd_buffer_pointer(nic_t *sp, RxD_t *rxdp, buffAdd_t *ba,
((RxD3_t*)rxdp)->Buffer1_ptr = *temp1; ((RxD3_t*)rxdp)->Buffer1_ptr = *temp1;
} else { } else {
*skb = dev_alloc_skb(size); *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 = ((RxD3_t*)rxdp)->Buffer2_ptr = *temp2 =
pci_map_single(sp->pdev, (*skb)->data, pci_map_single(sp->pdev, (*skb)->data,
dev->mtu + 4, dev->mtu + 4,
...@@ -6007,7 +6012,11 @@ static int set_rxd_buffer_pointer(nic_t *sp, RxD_t *rxdp, buffAdd_t *ba, ...@@ -6007,7 +6012,11 @@ static int set_rxd_buffer_pointer(nic_t *sp, RxD_t *rxdp, buffAdd_t *ba,
((RxD3_t*)rxdp)->Buffer2_ptr = *temp2; ((RxD3_t*)rxdp)->Buffer2_ptr = *temp2;
} else { } else {
*skb = dev_alloc_skb(size); *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 = ((RxD3_t*)rxdp)->Buffer0_ptr = *temp0 =
pci_map_single(sp->pdev, ba->ba_0, BUF0_LEN, pci_map_single(sp->pdev, ba->ba_0, BUF0_LEN,
PCI_DMA_FROMDEVICE); PCI_DMA_FROMDEVICE);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册