Received: by 10.223.185.116 with SMTP id b49csp5958830wrg; Wed, 7 Mar 2018 22:40:01 -0800 (PST) X-Google-Smtp-Source: AG47ELsE35gi7wG5BcA0ebODa6h+CGCi11dGzP7PUAd8qNJVKzavTuMVurRO3BdZRRUHlJgUHVWm X-Received: by 10.98.245.131 with SMTP id b3mr25390665pfm.20.1520491201815; Wed, 07 Mar 2018 22:40:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520491201; cv=none; d=google.com; s=arc-20160816; b=U+p6hHxT8F+EWM5P5Buf1pUG43HMzmGu0TBdoVFElJ2sS/YdeN0atliV5smuEL4Et2 e3MD9Jidgm7RvvYbKlKVKatnZ2m+ga+1K18RFzUiRSff52VXOayTcQBogW1V5xryNeYT GEQezd03NDsZX/juLgWNOLgXs7xmyhJqKTHO7TUHouDvQkvcwntCKlJt/EQwbhG516E7 ZioOKvX79PfCoWXPT31Rki4rQE8mjILjNj4IDiAoz8It6+eUCCtroOLcZ9Jy1rznZfa4 ECZpDDl8ByO55C7osmCtFMYU1U0gUGAZD69QGYMVUGRTMi/wbFYxB8pIHjzYGlWWzuLC PxTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=Y32cmxpt0k6D+MFOVCSdL7bchDh74FQCLkL3xxLVsOs=; b=AyMmtRdZkrgX5qD5NfFRoabM4uMID5zNrCqvEvFNmlsFlhR3TuUKmo81W37s8nm0m6 ze5H1G37pn6oR8ZtqAqDmPaGw91PGRakEXP27/JLupHX0KIagbwFsTwcI+Da++9Wl9kA FkjSMqdcI39yEE61Qc4fn8OfW7XmUurNbgO09FUp11X2V6ApC3nEEa7kkVknNaPiwbTf p4pMPcxIXUGWAORFOK+hkb+CsosfpUX4Sj9/HFsn59DfZS0ozSXHjTvVH+jhFfee/jrK /kS06/K0puBUdttbBzDn8nfM9p5q8c3ZDmNMY5SaRzAN7bh+1NEBjAV7eUO29xs29R9X okNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=aJj1LinG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l14si12445712pgc.615.2018.03.07.22.39.47; Wed, 07 Mar 2018 22:40:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=aJj1LinG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965210AbeCHGiO (ORCPT + 99 others); Thu, 8 Mar 2018 01:38:14 -0500 Received: from mail-co1nam03on0126.outbound.protection.outlook.com ([104.47.40.126]:14720 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935383AbeCHE7M (ORCPT ); Wed, 7 Mar 2018 23:59:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Y32cmxpt0k6D+MFOVCSdL7bchDh74FQCLkL3xxLVsOs=; b=aJj1LinGxuXe4LO+tfDWf9lnUHKlXpy53V8wwHwzkKdEUA+I8v5KnnIivMgCUtBvo4R5uAhevW7+e9kW0N/IxqSpY9O9AROGOqWD2uY4H97qVzaW+g5Yl8jvWlA0ApnCvuHWs2PRQ/RDIGPU7boEeKK7Uq5SbxOR2m+XboeKixc= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0999.namprd21.prod.outlook.com (52.132.133.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.588.7; Thu, 8 Mar 2018 04:59:10 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8063:c68a:b210:7446]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8063:c68a:b210:7446%2]) with mapi id 15.20.0588.008; Thu, 8 Mar 2018 04:59:10 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Haishuang Yan , William Tu , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 55/67] ip_gre: fix potential memory leak in erspan_rcv Thread-Topic: [PATCH AUTOSEL for 4.14 55/67] ip_gre: fix potential memory leak in erspan_rcv Thread-Index: AQHTtpoFKIcqDtfUnUGz+dUTHbHPuw== Date: Thu, 8 Mar 2018 04:57:55 +0000 Message-ID: <20180308045641.7814-55-alexander.levin@microsoft.com> References: <20180308045641.7814-1-alexander.levin@microsoft.com> In-Reply-To: <20180308045641.7814-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0999;7:ejIUS7sFFCHCQf4xcNYlfiGUrNsSltBmcm30dyanJYopAK5ueOdIwu3t+dboZvfIJLiLleDsx//ZuyOtLOxoMSal+CqV747sFBxkcXPNU3Sd92l10WTFZ9pE/HaYPVlLROtrTirBcWdGT3MfqYyxkrafnNWOJTldju20nHJ50ubyuO57xnVabH/MZ4i/XdKSY8NxAzYd6LyslqZjkqNk+WaCKosgpErz5i0afVK/U8/Rkk4hD13IzVDVyAMWoe4h;20:h8v7er/SJEUOcx43bmtKUQtgaL1teDG1/+agUxEKlIqVfVZWAJUUcQEL/asgi/yndFvR8CrsSiNlXKlMVYKV6gl3RUCCmQynjdBM/aAFIbywVn91EQ97RSYiQb1SSTJ2VHLeCozyz//M4IinMhUCb4GRkO1ehzSnpZRIg5cn9c4= x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 1d6bafa2-9b88-4be8-2124-08d584b1549d x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0999; x-ms-traffictypediagnostic: DM5PR2101MB0999: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(173505980823694)(85827821059158); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040501)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3002001)(3231220)(944501244)(52105095)(6055026)(61426038)(61427038)(6041288)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(6072148)(201708071742011);SRVR:DM5PR2101MB0999;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0999; x-forefront-prvs: 060503E79B x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(39860400002)(39380400002)(376002)(396003)(346002)(189003)(199004)(72206003)(3846002)(106356001)(8676002)(6116002)(1076002)(6512007)(14454004)(81156014)(66066001)(2906002)(3660700001)(478600001)(10290500003)(8936002)(6486002)(305945005)(7736002)(36756003)(2900100001)(81166006)(4326008)(25786009)(6436002)(5250100002)(105586002)(54906003)(22452003)(76176011)(5660300001)(10090500001)(110136005)(316002)(39060400002)(6506007)(86362001)(575784001)(186003)(2950100002)(97736004)(3280700002)(102836004)(99286004)(107886003)(59450400001)(68736007)(86612001)(53936002)(26005)(6666003)(2501003)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0999;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 3Hqew4151n3CRSln0mGhqDE2ifXzHzKNoANc6LyM4xA7BHz8qBSxGXhYO7wOLjUoXXQ/2Xs9/M4Z7FXSzGkHrkhYTovb+uJ5dnVThQgj5mBrSmPXEBd3lUi0/mr1WeIF/XTD7xey0wl7qtE1E4fxMFFTg/4Fpvy8hpgVojhucwi15Vn6hpnn9eQFGgVOLnmoK8QjEnEDs1tKPIiKrp/KRi5HxwzLm+qtZGXncCmNIumEq4SF1P4N+Xb4czeVVv64qtrsZ2POgHdgsmWzBwH1diCf14H9HoWThEI6IKyGWmESM7f1lmVTf2XrE6MgA96asad/bb3q4zxDBHD2S0HT4w== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d6bafa2-9b88-4be8-2124-08d584b1549d X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Mar 2018 04:57:55.8388 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0999 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Haishuang Yan [ Upstream commit 50670b6ee9bc4ae8f9ce3112b437987adf273245 ] If md is NULL, tun_dst must be freed, otherwise it will cause memory leak. Fixes: 1a66a836da6 ("gre: add collect_md mode to ERSPAN tunnel") Cc: William Tu Signed-off-by: Haishuang Yan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv4/ip_gre.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index e0cc6a38b701..5e0e0db341ca 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -303,8 +303,10 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_= ptk_info *tpi, return PACKET_REJECT; =20 md =3D ip_tunnel_info_opts(&tun_dst->u.tun_info); - if (!md) + if (!md) { + dst_release((struct dst_entry *)tun_dst); return PACKET_REJECT; + } =20 md->index =3D index; info =3D &tun_dst->u.tun_info; --=20 2.14.1