From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Dichtel Subject: Re: [PATCH linux-next 1/4] infiniband/ipoib: fix possible NULL pointer dereference in ipoib_get_iflink Date: Tue, 14 Apr 2015 18:46:22 +0200 Message-ID: <552D445E.3040503@6wind.com> References: <1429024817-21561-1-git-send-email-honli@redhat.com> <1429024817-21561-2-git-send-email-honli@redhat.com> Reply-To: nicolas.dichtel-pdR9zngts4EAvxtiuMwx3w@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: In-Reply-To: Sender: linux-rdma-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Erez Shitrit , Honggang Li Cc: Roland Dreier , sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org, hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, kaber-dcUjhNyLwpNeoWH0uzbU5w@public.gmane.org, davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org, Alex Estrin , Doug Ledford , edumazet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org, Erez Shitrit , maheshb-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org, jbenc-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org, elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org, f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org, andrew-g2DYL2Zd6BY@public.gmane.org, sfeldma-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, alexander.h.duyck-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org, "linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: linux-rdma@vger.kernel.org Le 14/04/2015 18:30, Erez Shitrit a =C3=A9crit : > On Tue, Apr 14, 2015 at 6:20 PM, Honggang Li wrote= : [snip] > This will make parent interface to return 0 instead of its own ifinde= x. > I would suggest write something like that: > > + /* parent interface */ > + if (!test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags)) > + return dev->ifindex; > + > + /* child/vlan interface */ > + if (!priv->parent) > + return -1; 'return 0' here. -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" i= n the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933029AbbDNQqe (ORCPT ); Tue, 14 Apr 2015 12:46:34 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:35552 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932998AbbDNQq0 (ORCPT ); Tue, 14 Apr 2015 12:46:26 -0400 Message-ID: <552D445E.3040503@6wind.com> Date: Tue, 14 Apr 2015 18:46:22 +0200 From: Nicolas Dichtel Reply-To: nicolas.dichtel@6wind.com Organization: 6WIND User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Erez Shitrit , Honggang Li CC: Roland Dreier , sean.hefty@intel.com, hal.rosenstock@gmail.com, kaber@trash.net, davem@davemloft.net, Alex Estrin , Doug Ledford , edumazet@google.com, Erez Shitrit , 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 Subject: Re: [PATCH linux-next 1/4] infiniband/ipoib: fix possible NULL pointer dereference in ipoib_get_iflink References: <1429024817-21561-1-git-send-email-honli@redhat.com> <1429024817-21561-2-git-send-email-honli@redhat.com> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 14/04/2015 18:30, Erez Shitrit a écrit : > On Tue, Apr 14, 2015 at 6:20 PM, Honggang Li wrote: [snip] > This will make parent interface to return 0 instead of its own ifindex. > I would suggest write something like that: > > + /* parent interface */ > + if (!test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags)) > + return dev->ifindex; > + > + /* child/vlan interface */ > + if (!priv->parent) > + return -1; 'return 0' here.