LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Levitsky Maxim <maximlevitsky@yahoo.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [NET] dmfe : number of fixes and features
Date: Wed, 7 Feb 2007 09:59:41 -0800 (PST)	[thread overview]
Message-ID: <386082.5155.qm@web38501.mail.mud.yahoo.com> (raw)

From: Maxim Levitsky <maximlevitsky@yahoo.com>
Subject: [PATCH] [NET] [002] dmfe : Fix possible oops

Deallocate memory after driver is unregistred to prevent oops
Don't dereference NULL pointer that can be returned by dev_alloc_skb in case of oom

Signed-off-by: Maxim Levitsky <maximlevitsky@yahoo.com>

---

--- linux-2.6.20-mod/drivers/net/tulip/dmfe.c	2007-02-07 18:27:07.000000000 +0200
+++ linux-2.6.20-test/drivers/net/tulip/dmfe.c	2007-02-07 18:27:59.000000000 +0200
@@ -497,13 +497,16 @@ static void __devexit dmfe_remove_one (s
 	DMFE_DBUG(0, "dmfe_remove_one()", 0);
 
  	if (dev) {
+		
+		unregister_netdev(dev);
+		pci_release_regions(pdev);
+		
+		
 		pci_free_consistent(db->pdev, sizeof(struct tx_desc) *
 					DESC_ALL_CNT + 0x20, db->desc_pool_ptr,
  					db->desc_pool_dma_ptr);
 		pci_free_consistent(db->pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4,
 					db->buf_pool_ptr, db->buf_pool_dma_ptr);
-		unregister_netdev(dev);
-		pci_release_regions(pdev);
 		free_netdev(dev);	/* free board information */
 		pci_set_drvdata(pdev, NULL);
 	}
@@ -921,7 +924,7 @@ static inline u32 cal_CRC(unsigned char 
 static void dmfe_rx_packet(struct DEVICE *dev, struct dmfe_board_info * db)
 {
 	struct rx_desc *rxptr;
-	struct sk_buff *skb;
+	struct sk_buff *skb, *newskb;
 	int rxlen;
 	u32 rdes0;
 
@@ -974,8 +977,10 @@ static void dmfe_rx_packet(struct DEVICE
 					/* Good packet, send to upper layer */
 					/* Shorst packet used new SKB */
 					if ( (rxlen < RX_COPY_SIZE) &&
-						( (skb = dev_alloc_skb(rxlen + 2) )
+						( (newskb = dev_alloc_skb(rxlen + 2) )
 						!= NULL) ) {
+						
+						skb = newskb;
 						/* size less than COPY_SIZE, allocate a rxlen SKB */
 						skb->dev = dev;
 						skb_reserve(skb, 2); /* 16byte align */



 
____________________________________________________________________________________
Expecting? Get great news right away with email Auto-Check. 
Try the Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html 

             reply	other threads:[~2007-02-07 17:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-07 17:59 Levitsky Maxim [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-02-07 18:04 Levitsky Maxim
2007-02-07 18:00 Levitsky Maxim
2007-02-07 18:00 Levitsky Maxim
2007-02-07 17:59 Levitsky Maxim
2007-02-07 17:57 Levitsky Maxim
2007-02-07 18:03 ` Randy Dunlap
2007-02-07 18:16   ` Levitsky Maxim
2007-02-07 19:13 ` Ismail Dönmez
2007-02-07 21:36   ` Levitsky Maxim

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=386082.5155.qm@web38501.mail.mud.yahoo.com \
    --to=maximlevitsky@yahoo.com \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH] [NET] dmfe : number of fixes and features' \
    /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

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).