From patchwork Thu Dec 21 23:51:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Tu X-Patchwork-Id: 852177 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kDW/gmpt"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3z2pMD4F0Nz9s81 for ; Fri, 22 Dec 2017 10:51:36 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755264AbdLUXve (ORCPT ); Thu, 21 Dec 2017 18:51:34 -0500 Received: from mail-pl0-f67.google.com ([209.85.160.67]:43538 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755184AbdLUXvd (ORCPT ); Thu, 21 Dec 2017 18:51:33 -0500 Received: by mail-pl0-f67.google.com with SMTP id z5so11922357plo.10 for ; Thu, 21 Dec 2017 15:51:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=uq6BNc/E7//cZUKS0GLqi9Qbn8c7/v1jw2OBOhstqRE=; b=kDW/gmptzgJItcLrs9AwGAB6XFfzHKY6JwmDyXkIm9A5G1nJTokN5wytMmviiwdaPs gGARkyuzsHlzV2shhPgKdUQaQHr0ZFFqRA9N46DpTET2/s5OvSRcfpccGWOaWiT7zFkS M3BgADyuht/kdW2V39mVVpH0vrfYrcty5nWBoK1SvVs7v6fuQmrEo1BxPDZiBX7LpZaL lyyduxfC14NQkRQsQiuu92n+AjRam+9hgdNiOgLMWWjQBooe/YMssW60mlACaDIEjwvB 9DvGXidxFtitxF2SbA/TAb1Os4oJwYNKPg3GSWCs5XzRMlMjslL+4Q49NkRn2MtfMlCo a3Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=uq6BNc/E7//cZUKS0GLqi9Qbn8c7/v1jw2OBOhstqRE=; b=ArJZ1QgOVbESOORyJm8ub9FJgueIXKRE8SKwwQJSuNRIVRq7vwDBVgSJI5MVVTUX4J jkHtJ/Vt9UGAkSvv/seYTWgNrwMni26YRitZTAbNKr9MpBlbFLR6SEMSwQovYVSx8+tk M3ndE2JkXySpPg5fHUq0F0PcUG6W20i62fDM/DdvHIdluXLQuCbz0cm7vkg5FUnnn/O/ Fu01Tl9S4lSi8B97mVLSbC6K2PozOGttpRAFwGi+CMFAA7FiZlzItlU5Zl3dy+8tKfVu WOm8tQUNfp0VHJnEm7WWHtNvzLGdx5vsEhodcAl0BreJbx1qdCkT8NH0ViOAUkuWz9jx 94BQ== X-Gm-Message-State: AKGB3mJE4x0S44Tk8vV3CXN+7N47baqGa0xdhCESaMy64JqHRUWhuJQu vZvQjkESXpCIMQb13X/CM0ys5Lni X-Google-Smtp-Source: ACJfBouoOKROVi92xzLrp3WGBh6wfIFn1c0K8j6cGECVFMrXRVSXnbZIhEpeXe1+mjBmFPNXZ6zQAw== X-Received: by 10.159.198.70 with SMTP id y6mr12333172plt.334.1513900292286; Thu, 21 Dec 2017 15:51:32 -0800 (PST) Received: from sc9-mailhost2.vmware.com ([208.91.2.1]) by smtp.gmail.com with ESMTPSA id i85sm42030857pfi.54.2017.12.21.15.51.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Dec 2017 15:51:31 -0800 (PST) From: William Tu To: netdev@vger.kernel.org Cc: Haishuang Yan Subject: [PATCH net-next] net: erspan: remove md NULL check Date: Thu, 21 Dec 2017 15:51:22 -0800 Message-Id: <1513900282-8439-1-git-send-email-u9012063@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The 'md' is allocated from 'tun_dst = ip_tun_rx_dst' and since we've checked 'tun_dst', 'md' will never be NULL. The patch removes it at both ipv4 and ipv6 erspan. Fixes: afb4c97d90e6 ("ip6_gre: fix potential memory leak in ip6erspan_rcv") Fixes: 50670b6ee9bc ("ip_gre: fix potential memory leak in erspan_rcv") Cc: Haishuang Yan Signed-off-by: William Tu --- net/ipv4/ip_gre.c | 5 ----- net/ipv6/ip6_gre.c | 4 ---- 2 files changed, 9 deletions(-) diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index 90c912307814..47c7de3ca458 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -313,11 +313,6 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi, return PACKET_REJECT; md = ip_tunnel_info_opts(&tun_dst->u.tun_info); - if (!md) { - dst_release((struct dst_entry *)tun_dst); - return PACKET_REJECT; - } - memcpy(md, pkt_md, sizeof(*md)); md->version = ver; diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index 8451d00b210b..1aabc8df7cb7 100644 --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c @@ -550,10 +550,6 @@ static int ip6erspan_rcv(struct sk_buff *skb, int gre_hdr_len, info = &tun_dst->u.tun_info; md = ip_tunnel_info_opts(info); - if (!md) { - dst_release((struct dst_entry *)tun_dst); - return PACKET_REJECT; - } memcpy(md, pkt_md, sizeof(*md)); md->version = ver;