Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10423908ybi; Wed, 24 Jul 2019 22:59:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqzVSZ0ufkm1L9v8NY6kIkb8UKwD3/KCqJoBkuwBxDUDiqji0/u0LHN17D7KzV8wk1NPJvR2 X-Received: by 2002:a17:90a:80c4:: with SMTP id k4mr92249535pjw.74.1564034342606; Wed, 24 Jul 2019 22:59:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564034342; cv=none; d=google.com; s=arc-20160816; b=Ip4dnjxrDPlrTLwqK6tf29CuaO8GmnfudvdaCRAAG/AYxoMCpwmfUw0yqJRO5yjU0S v6zLnNXcvH4XLoos9JLyjCwJwdaj6l8hRNOkzH73z8nKildiZYhc9QhXVhE6qDIk1C7a r01ZSLinm05ehLkGe+lvfBqUscyPmqgvHuqiuec/mndgfXLAQaHbUZRUozXbrEMv/9zH FGlijhwSWVhkgm+gmbYIJAGluX0wfj/P1rS+QYIKi6Drj2BW8566L6sso2P9jnV77gMI /Y5untcf9uHEszwAq+rIfKR+tecEKAfPNdM3pFcq30TzI+KdxTevRQLEQEWG0qv7uSf6 WB3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RFs+o/iek3jGgY9NwBZnUcb5jLwo4IVtsgem+4zoLwg=; b=LlBFEuK2dNuI9smt16XhdRzBkePxn1kC9E7OeUKCUZ4rDboldMcKpJR+kaFkmaipcd DCbZ8/FxMkyyWJJsxgMRXAaD/WMufIBeuVR/M2ztPa+pxuC8EqF2mjqp8QKkFYs/QP90 WgisXVOtB0I2FqO5VHBqxCnAYDXIGKgdfULFrr2Y+bscO55QNdGQVL3IUIolhP0MOUBa p9YuzOuMuYPRwOA7vV+caYt+o3W6fldvj9da5o5wWzQSPbUGc6Vf9XFkvOtkikIwrO/G REENpoEwQkfj0qlV2uKBUpmTg191yfEm32R1VYpTKHWL0sRJ9fms9d4fAc1MBpe6LWLX EBrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rWhhrhId; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d3si16062454pgv.492.2019.07.24.22.58.48; Wed, 24 Jul 2019 22:59:02 -0700 (PDT) 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=@kernel.org header.s=default header.b=rWhhrhId; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404600AbfGYFlS (ORCPT + 99 others); Thu, 25 Jul 2019 01:41:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:56044 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404592AbfGYFlR (ORCPT ); Thu, 25 Jul 2019 01:41:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5BD5322BEB; Thu, 25 Jul 2019 05:41:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564033276; bh=YT/Ya2QuCV54Ta5zpV7aCETVkK9+itqi5z18Zxh8/2Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rWhhrhIdACChJ6I1UOtvAeGByvh1CbJPRtc1o62AZaxP/IY2Xz7kNlt45mY/6tohS uyNKI2dOd3meAE0cvPIP1Oi2hg9jnnMAd3p+uJApM09YQ/Un6u9XUEicn3u2lwPN17 vBK3RCyCvPg7OlPJdfzMYHYoB96jXOCt/0ddKoX4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Taehee Yoo , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 152/271] gtp: add missing gtp_encap_disable_sock() in gtp_encap_enable() Date: Wed, 24 Jul 2019 21:20:21 +0200 Message-Id: <20190724191708.235785958@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191655.268628197@linuxfoundation.org> References: <20190724191655.268628197@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit e30155fd23c9c141cbe7d99b786e10a83a328837 ] If an invalid role is sent from user space, gtp_encap_enable() will fail. Then, it should call gtp_encap_disable_sock() but current code doesn't. It makes memory leak. Fixes: 91ed81f9abc7 ("gtp: support SGSN-side tunnels") Signed-off-by: Taehee Yoo Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/gtp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c index 7a145172d503..83488f2bf7a0 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c @@ -847,8 +847,13 @@ static int gtp_encap_enable(struct gtp_dev *gtp, struct nlattr *data[]) if (data[IFLA_GTP_ROLE]) { role = nla_get_u32(data[IFLA_GTP_ROLE]); - if (role > GTP_ROLE_SGSN) + if (role > GTP_ROLE_SGSN) { + if (sk0) + gtp_encap_disable_sock(sk0); + if (sk1u) + gtp_encap_disable_sock(sk1u); return -EINVAL; + } } gtp->sk0 = sk0; -- 2.20.1