From patchwork Sat Apr 11 12:08:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 228107 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45068C2BB85 for ; Sat, 11 Apr 2020 12:10:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1CD782166E for ; Sat, 11 Apr 2020 12:10:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586607050; bh=Lq+c0hsqiUVZu7vthld/EVB7dfPYmMTCezE13xmjMxk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=HTyNmWhvVSJ2sgE5NxiSVSKh2Z8Ir5qYoCjo6DuGJXiKI9U2/FoBWmpcE2tQOb0Ch NOr6OcNMAetW3domQpzG0Q4/5CCPSgLtdYveiHzln0EVe06p+a5AUU8Z2zZDo/zRC6 BS3ul/xrIGNoUXYBS/PbzG/bYgcLWLfbeeRHN07I= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726703AbgDKMKs (ORCPT ); Sat, 11 Apr 2020 08:10:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:42452 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726715AbgDKMKr (ORCPT ); Sat, 11 Apr 2020 08:10:47 -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 1A0B42084D; Sat, 11 Apr 2020 12:10:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586607046; bh=Lq+c0hsqiUVZu7vthld/EVB7dfPYmMTCezE13xmjMxk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vbNNlrpRROXFUKWVnsCve8ghTQVG1FPONMsRuHeRobC0Fkb+05PaVv0sk1UNk+L5g 1FLzDl13tVf5CIUbljHpwi1zLl3spvrK1AYeS6wV2rvcqeIV1ixu4jC7qrVuPrCjTr 8Z8E2oPbfesbn0q2yIEMbHAYTwH7FuaQX4lcoMOY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Phil Turnbull , "David S. Miller" , Will Deacon Subject: [PATCH 4.4 05/29] l2tp: Correctly return -EBADF from pppol2tp_getname. Date: Sat, 11 Apr 2020 14:08:35 +0200 Message-Id: <20200411115408.341698005@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200411115407.651296755@linuxfoundation.org> References: <20200411115407.651296755@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: phil.turnbull@oracle.com commit 4ac36a4adaf80013a60013d6f829f5863d5d0e05 upstream. If 'tunnel' is NULL we should return -EBADF but the 'end_put_sess' path unconditionally sets 'error' back to zero. Rework the error path so it more closely matches pppol2tp_sendmsg. Fixes: fd558d186df2 ("l2tp: Split pppol2tp patch into separate l2tp and ppp parts") Signed-off-by: Phil Turnbull Signed-off-by: David S. Miller Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- net/l2tp/l2tp_ppp.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) --- a/net/l2tp/l2tp_ppp.c +++ b/net/l2tp/l2tp_ppp.c @@ -889,10 +889,8 @@ static int pppol2tp_getname(struct socke pls = l2tp_session_priv(session); tunnel = l2tp_sock_to_tunnel(pls->tunnel_sock); - if (tunnel == NULL) { - error = -EBADF; + if (tunnel == NULL) goto end_put_sess; - } inet = inet_sk(tunnel->sock); if ((tunnel->version == 2) && (tunnel->sock->sk_family == AF_INET)) { @@ -970,12 +968,11 @@ static int pppol2tp_getname(struct socke } *usockaddr_len = len; + error = 0; sock_put(pls->tunnel_sock); end_put_sess: sock_put(sk); - error = 0; - end: return error; }