From patchwork Wed Mar 9 04:47:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jason Liu X-Patchwork-Id: 457 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:42:47 -0000 Delivered-To: patches@linaro.org Received: by 10.224.60.68 with SMTP id o4cs47481qah; Tue, 8 Mar 2011 20:47:32 -0800 (PST) Received: by 10.231.211.196 with SMTP id gp4mr4534995ibb.122.1299646052195; Tue, 08 Mar 2011 20:47:32 -0800 (PST) Received: from mail-iy0-f178.google.com (mail-iy0-f178.google.com [209.85.210.178]) by mx.google.com with ESMTPS id i10si3803886iby.64.2011.03.08.20.47.32 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 08 Mar 2011 20:47:32 -0800 (PST) Received-SPF: pass (google.com: domain of liu.h.jason@gmail.com designates 209.85.210.178 as permitted sender) client-ip=209.85.210.178; Authentication-Results: mx.google.com; spf=pass (google.com: domain of liu.h.jason@gmail.com designates 209.85.210.178 as permitted sender) smtp.mail=liu.h.jason@gmail.com; dkim=pass (test mode) header.i=@gmail.com Received: by iyj8 with SMTP id 8so202925iyj.37 for ; Tue, 08 Mar 2011 20:47:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=byzoW/Vh4aghqpGEPre4MY7430Rj4wiwn/M833kWb0I=; b=fsMYXkoaHoyj7kMVX2lSpYPciiGuu29kGDMK/pAG+ssz/2C53N0y2JCyM8Bq6eJmxD zjmVhlTnqb+xdpvrYVRH11dM2SG65RtbhBN0BvARXqzB5crp3hMYCzgRps0fnb2gGcEQ q23ed5sMTuJjp5VbDqmmb07UzZrkMSEyJJqD8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=n1e6lYW5vpWpayFiPHQQ/b7ON6YPCPn7UueBQcgE2rBnZAebBXL7i1K7TcVvB0UCGP nGnIeJ06CATKjliwwWpRs4HpJ0tCjbNQyIBSBbTnSuV5UC7Lxggdoj6eKkd9af/l95B1 +Ef64N6OZygdVNNEmoA3Od2KcoAtXUKWIBRdE= MIME-Version: 1.0 Received: by 10.42.227.199 with SMTP id jb7mr6324694icb.196.1299646051744; Tue, 08 Mar 2011 20:47:31 -0800 (PST) Received: by 10.42.227.4 with HTTP; Tue, 8 Mar 2011 20:47:31 -0800 (PST) In-Reply-To: <1299639004-21546-1-git-send-email-jason.hui@linaro.org> References: <1299639004-21546-1-git-send-email-jason.hui@linaro.org> Date: Wed, 9 Mar 2011 12:47:31 +0800 Message-ID: Subject: Fwd: [PATCH] net/fec: check id_entry pointer before using it From: Jason Liu To: patches@linaro.org ---------- Forwarded message ---------- From: Jason Liu Date: 2011/3/9 Subject: [PATCH] net/fec: check id_entry pointer before using it To: linux-arm-kernel@lists.infradead.org 抄送: davem@davemloft.net The id_entry will possibly be NULL, So, need check id_entry and make sure it not NULL before using it. Signed-off-by: Jason Liu --- drivers/net/fec.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) /* Save skb pointer */ @@ -530,7 +530,7 @@ fec_enet_rx(struct net_device *dev) dma_unmap_single(NULL, bdp->cbd_bufaddr, bdp->cbd_datlen, DMA_FROM_DEVICE); - if (id_entry->driver_data & FEC_QUIRK_SWAP_FRAME) + if (id_entry && id_entry->driver_data & FEC_QUIRK_SWAP_FRAME) swap_buffer(data, pkt_len); /* This does 16 byte alignment, exactly what we need. @@ -809,7 +809,7 @@ static int fec_enet_mii_init(struct platform_device *pdev) * mdio interface in board design, and need to be configured by * fec0 mii_bus. */ - if ((id_entry->driver_data & FEC_QUIRK_ENET_MAC) && pdev->id) { + if (id_entry && (id_entry->driver_data & FEC_QUIRK_ENET_MAC) && pdev->id) { /* fec1 uses fec0 mii_bus */ fep->mii_bus = fec0_mii_bus; return 0; @@ -852,7 +852,7 @@ static int fec_enet_mii_init(struct platform_device *pdev) goto err_out_free_mdio_irq; /* save fec0 mii_bus */ - if (id_entry->driver_data & FEC_QUIRK_ENET_MAC) + if (id_entry && id_entry->driver_data & FEC_QUIRK_ENET_MAC) fec0_mii_bus = fep->mii_bus; return 0; @@ -1239,7 +1239,7 @@ fec_restart(struct net_device *dev, int duplex) * enet-mac reset will reset mac address registers too, * so need to reconfigure it. */ - if (id_entry->driver_data & FEC_QUIRK_ENET_MAC) { + if (id_entry && id_entry->driver_data & FEC_QUIRK_ENET_MAC) { memcpy(&temp_mac, dev->dev_addr, ETH_ALEN); writel(cpu_to_be32(temp_mac[0]), fep->hwp + FEC_ADDR_LOW); writel(cpu_to_be32(temp_mac[1]), fep->hwp + FEC_ADDR_HIGH); @@ -1295,7 +1295,7 @@ fec_restart(struct net_device *dev, int duplex) * The phy interface and speed need to get configured * differently on enet-mac. */ - if (id_entry->driver_data & FEC_QUIRK_ENET_MAC) { + if (id_entry && id_entry->driver_data & FEC_QUIRK_ENET_MAC) { val = readl(fep->hwp + FEC_R_CNTRL); /* MII or RMII */ -- 1.7.1 diff --git a/drivers/net/fec.c b/drivers/net/fec.c index cd0282d..e97ee0f 100644 --- a/drivers/net/fec.c +++ b/drivers/net/fec.c @@ -294,7 +294,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) * the system that it's running on. As the result, driver has to * swap every frame going to and coming from the controller. */ - if (id_entry->driver_data & FEC_QUIRK_SWAP_FRAME) + if (id_entry && id_entry->driver_data & FEC_QUIRK_SWAP_FRAME) swap_buffer(bufaddr, skb->len);