netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jia-Ju Bai <baijiaju1990@163.com>
To: David Miller <davem@davemloft.net>, netdev@vger.kernel.org
Cc: e1000-devel@lists.sourceforge.net, linux.nics@intel.com,
	sergei.shtylyov@cogentembedded.com,
	Linux-nics@isotope.jf.intel.com
Subject: [PATCH V2 1/2] e100 in linux-3.18.0: Fix null pointer deference in e100_probe
Date: Sun, 21 Dec 2014 09:19:59 +0800	[thread overview]
Message-ID: <5496203F.9000000@163.com> (raw)
In-Reply-To: <20141220.143005.1130435723139487537.davem@davemloft.net>


[-- Attachment #1.1: Type: text/plain, Size: 1280 bytes --]

The driver lacks the check of nic->cbs_pool after pci_pool_create in e100_probe. So when this function is failed, the null pointer dereference occurs when pci_pool_alloc uses nic->cbs_pool in e100_alloc_cbs.
This patch fix this problem, and it has been tested in runtime.

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

diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
index 781065e..ba1813f 100644
--- a/drivers/net/ethernet/intel/e100.c
+++ b/drivers/net/ethernet/intel/e100.c
@@ -2969,6 +2969,10 @@ static int e100_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                nic->params.cbs.max * sizeof(struct cb),
                sizeof(u32),
                0);
+   if (!nic->cbs_pool) {
+       err = -ENOMEM;
+       goto err_out_pool;
+   }
     netif_info(nic, probe, nic->netdev,
            "addr 0x%llx, irq %d, MAC addr %pM\n",
            (unsigned long long)pci_resource_start(pdev, use_io ? 1 : 0),
@@ -2976,6 +2980,8 @@ static int e100_probe(struct pci_dev *pdev, const struct pci_device_id *ent)

     return 0;

+err_out_pool:
+   unregister_netdev(netdev);
  err_out_free:
     e100_free(nic);
  err_out_iounmap:



[-- Attachment #2: Type: text/plain, Size: 441 bytes --]

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk

[-- Attachment #3: Type: text/plain, Size: 257 bytes --]

_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel&#174; Ethernet, visit http://communities.intel.com/community/wired

  parent reply	other threads:[~2014-12-21  1:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-20 14:32 [PATCH] e100 in linux-3.18.0: some potential bugs Jia-Ju Bai
2014-12-20 15:07 ` Sergei Shtylyov
2014-12-20 19:30 ` David Miller
2014-12-21  0:52   ` [PATCH V2] e1000: Add netif_napi_del in the normal path and error path to match netif_napi_add Jia-Ju Bai
2014-12-21 13:57     ` Sergei Shtylyov
2014-12-21  1:19   ` Jia-Ju Bai [this message]
2014-12-21 14:02     ` [PATCH V2 1/2] e100 in linux-3.18.0: Fix null pointer deference in e100_probe Sergei Shtylyov
2014-12-21  1:51   ` [PATCH V2 2/2] e100 in linux-3.18.0: Add netif_napi_del in the normal path and error path to match netif_napi_add Jia-Ju Bai

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=5496203F.9000000@163.com \
    --to=baijiaju1990@163.com \
    --cc=Linux-nics@isotope.jf.intel.com \
    --cc=davem@davemloft.net \
    --cc=e1000-devel@lists.sourceforge.net \
    --cc=linux.nics@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=sergei.shtylyov@cogentembedded.com \
    /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).