From patchwork Tue Apr 14 15:20:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 6216711 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 39789BF4A6 for ; Tue, 14 Apr 2015 15:22:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6B53C201F2 for ; Tue, 14 Apr 2015 15:22:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7520820212 for ; Tue, 14 Apr 2015 15:22:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755863AbbDNPWC (ORCPT ); Tue, 14 Apr 2015 11:22:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52032 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753922AbbDNPV7 (ORCPT ); Tue, 14 Apr 2015 11:21:59 -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 t3EFLTFU001278 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 14 Apr 2015 11:21:29 -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 t3EFKljf002520; Tue, 14 Apr 2015 11:21:23 -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 3/4] macvlan: fix possible NULL pointer dereference in macvlan_dev_get_iflink Date: Tue, 14 Apr 2015 23:20:16 +0800 Message-Id: <1429024817-21561-4-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: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Honggang Li --- drivers/net/macvlan.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index b227a13..1e59f39 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -998,7 +998,9 @@ static int macvlan_dev_get_iflink(const struct net_device *dev) { struct macvlan_dev *vlan = netdev_priv(dev); - return vlan->lowerdev->ifindex; + if (vlan && vlan->lowerdev) + return vlan->lowerdev->ifindex; + return 0; } static const struct ethtool_ops macvlan_ethtool_ops = {