netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jia-Ju Bai <baijiaju1990@gmail.com>
To: jeffrey.t.kirsher@intel.com, davem@davemloft.net
Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, Jia-Ju Bai <baijiaju1990@gmail.com>
Subject: [PATCH] net: e1000: Fix some bugs in error handling code of e1000_probe()
Date: Fri,  3 May 2019 22:28:23 +0800	[thread overview]
Message-ID: <20190503142823.15319-1-baijiaju1990@gmail.com> (raw)

When "hw->ce4100_gbe_mdio_base_virt = ioremap(...)" fails, the driver
does not free the memory allocated in e1000_sw_init(), and also calls
"iounmap(hw->ce4100_gbe_mido_base_virt)" that is unnecessary.

Besides, when e1000_sw_init() fails, the driver also calls 
"iounmap(hw->ce4100_gbe_mido_base_virt)" but 
hw->ce4100_gbe_mido_base_virt has not been assigned.

These bugs are found by a runtime fuzzing tool named FIZZER written by us.

To fix these bugs, the error handling code of e1000_probe() is adjusted.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
 drivers/net/ethernet/intel/e1000/e1000_main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c
index 8fe9af0e2ab7..7743c4d9723f 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_main.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
@@ -1227,12 +1227,12 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	if (hw->flash_address)
 		iounmap(hw->flash_address);
+	iounmap(hw->ce4100_gbe_mdio_base_virt);
+err_mdio_ioremap:
 	kfree(adapter->tx_ring);
 	kfree(adapter->rx_ring);
-err_dma:
 err_sw_init:
-err_mdio_ioremap:
-	iounmap(hw->ce4100_gbe_mdio_base_virt);
+err_dma:
 	iounmap(hw->hw_addr);
 err_ioremap:
 	disable_dev = !test_and_set_bit(__E1000_DISABLED, &adapter->flags);
-- 
2.17.0


                 reply	other threads:[~2019-05-03 14:35 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=20190503142823.15319-1-baijiaju1990@gmail.com \
    --to=baijiaju1990@gmail.com \
    --cc=davem@davemloft.net \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --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).