From patchwork Tue Apr 14 15:20:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 461179 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 919CD1402CF for ; Wed, 15 Apr 2015 01:22:16 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932704AbbDNPWM (ORCPT ); Tue, 14 Apr 2015 11:22:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57940 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755831AbbDNPWA (ORCPT ); Tue, 14 Apr 2015 11:22:00 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3EFLaLN032710 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 14 Apr 2015 11:21:37 -0400 Received: from honli.nay.redhat.com (dhcp-12-238.nay.redhat.com [10.66.12.238]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3EFKljg002520; Tue, 14 Apr 2015 11:21:30 -0400 From: Honggang Li To: roland@kernel.org, sean.hefty@intel.com, hal.rosenstock@gmail.com, kaber@trash.net, davem@davemloft.net, alex.estrin@intel.com, dledford@redhat.com, edumazet@google.com, erezsh@mellanox.com, nicolas.dichtel@6wind.com, maheshb@google.com, jbenc@redhat.com, ebiederm@xmission.com, elfring@users.sourceforge.net, f.fainelli@gmail.com, linux@roeck-us.net, andrew@lunn.ch, sfeldma@gmail.com, alexander.h.duyck@intel.com, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Honggang Li Subject: [PATCH linux-next 4/4] net/dsa: fix possible NULL pointer dereference in dsa_slave_get_iflink Date: Tue, 14 Apr 2015 23:20:17 +0800 Message-Id: <1429024817-21561-5-git-send-email-honli@redhat.com> In-Reply-To: <1429024817-21561-1-git-send-email-honli@redhat.com> References: <1429024817-21561-1-git-send-email-honli@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Signed-off-by: Honggang Li --- net/dsa/slave.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 827cda56..070b599 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -59,7 +59,10 @@ static int dsa_slave_get_iflink(const struct net_device *dev) { struct dsa_slave_priv *p = netdev_priv(dev); - return p->parent->dst->master_netdev->ifindex; + if (p && p->parent && p->parent->dst && p->parent->dst->master_netdev) + return p->parent->dst->master_netdev->ifindex; + else + return 0; } static inline bool dsa_port_is_bridged(struct dsa_slave_priv *p)