Skip to contentSkip to conversation

dl2k: potential null dereference in recieve_packet()

DISCUSSION Dan Carpenter 1 participant 1 message Jul 19, 2009

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

Hello,

Smatch (http://repo.or.cz/w/smatch.git) found a potential null dereference in drivers/net/dl2k.c receive_packet(). If the allocation on line 874 fails we still dereference skb on line 890.

drivers/net/dl2k.c
874 } else if ((skb = netdev_alloc_skb(dev, pkt_len + 2))) {
875 pci_dma_sync_single_for_cpu(np->pdev,

   876                                                              desc_to_dma(desc),
   877                                                              np->rx_buf_sz,
   878                                                              PCI_DMA_FROMDEVICE);
   879                                  /* 16 byte align the IP header */
   880                                  skb_reserve (skb, 2);
   881                                  skb_copy_to_linear_data (skb,
   882                                                    np->rx_skbuff[entry]->data,
   883                                                    pkt_len);
   884                                  skb_put (skb, pkt_len);
   885                                  pci_dma_sync_single_for_device(np->pdev,
   886                                                                 desc_to_dma(desc),
   887                                                                 np->rx_buf_sz,
   888                                                                 PCI_DMA_FROMDEVICE);

889 }
890 skb->protocol = eth_type_trans (skb, dev);

regards,
dan carpenter