From patchwork Sat Dec 4 12:31:41 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changli Gao X-Patchwork-Id: 74261 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4D1A8B70A3 for ; Sat, 4 Dec 2010 23:32:25 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754782Ab0LDMcU (ORCPT ); Sat, 4 Dec 2010 07:32:20 -0500 Received: from mail-iw0-f174.google.com ([209.85.214.174]:46720 "EHLO mail-iw0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754616Ab0LDMcT (ORCPT ); Sat, 4 Dec 2010 07:32:19 -0500 Received: by iwn6 with SMTP id 6so1056328iwn.19 for ; Sat, 04 Dec 2010 04:32:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=zt4iQj4ktbtdtBr+GEcpbWjyGwgz6n+cT7nPPqSLIqU=; b=IoxGfu/SMMZFLjUu6WB4NFlvTSprg+Kshf7xZEtOhwDHG88u8Kcv6N6N2ka1f7XQge 839IiBEft0+kR3UZq9/Zb5lvGx/6N8H9QmndICtrqUNnOJyK4UjLE9LXpVws8pfsF03o 618421kMeCDN7oWzoLo/QNpYyoWK8cgepSVfE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=Tx90QPc78OBfzyCbv+/CjAHyRDt5yh0hDxHO4JNiwf601nRWXOAJvUHi/jTlLiJ1R1 H8fwGCECdrGcmaa3viIL+ZTwNlONuq2e1gRzClf0s+uEbMgHMkwFQIpHdSb9wnc74BO5 GM/UT9wyzcCFWnfCT10uMYgSWTXNVPJfzOkjY= Received: by 10.231.37.195 with SMTP id y3mr3181169ibd.110.1291465938342; Sat, 04 Dec 2010 04:32:18 -0800 (PST) Received: from localhost.localdomain ([221.239.34.230]) by mx.google.com with ESMTPS id gy41sm2649974ibb.11.2010.12.04.04.32.05 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 04 Dec 2010 04:32:17 -0800 (PST) From: Changli Gao To: "David S. Miller" Cc: Eric Dumazet , Tom Herbert , Jiri Pirko , netdev@vger.kernel.org, Changli Gao Subject: [PATCH] net: init ingress queue Date: Sat, 4 Dec 2010 20:31:41 +0800 Message-Id: <1291465901-3189-1-git-send-email-xiaosuo@gmail.com> X-Mailer: git-send-email 1.7.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The dev field of ingress queue is forgot to initialized, then NULL pointer dereference happens in qdisc_alloc(). Move inits of tx queues to netif_alloc_netdev_queues(). Signed-off-by: Changli Gao Acked-by: Eric Dumazet --- v2: factorize the two inits in netdev_init_queues() and move inits of tx queues to netif_alloc_netdev_queues(). net/core/dev.c | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/core/dev.c b/net/core/dev.c index cd24374..4a7fc32 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5109,11 +5109,21 @@ static int netif_alloc_rx_queues(struct net_device *dev) } #endif +static void netdev_init_one_queue(struct net_device *dev, + struct netdev_queue *queue, void *_unused) +{ + /* Initialize queue lock */ + spin_lock_init(&queue->_xmit_lock); + netdev_set_xmit_lockdep_class(&queue->_xmit_lock, dev->type); + queue->xmit_lock_owner = -1; + netdev_queue_numa_node_write(queue, -1); + queue->dev = dev; +} + static int netif_alloc_netdev_queues(struct net_device *dev) { unsigned int count = dev->num_tx_queues; struct netdev_queue *tx; - int i; BUG_ON(count < 1); @@ -5125,27 +5135,10 @@ static int netif_alloc_netdev_queues(struct net_device *dev) } dev->_tx = tx; - for (i = 0; i < count; i++) { - netdev_queue_numa_node_write(&tx[i], -1); - tx[i].dev = dev; - } - return 0; -} - -static void netdev_init_one_queue(struct net_device *dev, - struct netdev_queue *queue, - void *_unused) -{ - /* Initialize queue lock */ - spin_lock_init(&queue->_xmit_lock); - netdev_set_xmit_lockdep_class(&queue->_xmit_lock, dev->type); - queue->xmit_lock_owner = -1; -} - -static void netdev_init_queues(struct net_device *dev) -{ netdev_for_each_tx_queue(dev, netdev_init_one_queue, NULL); spin_lock_init(&dev->tx_global_lock); + + return 0; } /** @@ -5184,8 +5177,6 @@ int register_netdevice(struct net_device *dev) dev->iflink = -1; - netdev_init_queues(dev); - /* Init, if this function is available */ if (dev->netdev_ops->ndo_init) { ret = dev->netdev_ops->ndo_init(dev);