Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2215042pxb; Fri, 25 Mar 2022 13:11:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxe7Yso3HsHJCAyz8ujR5emxvyU++cBPtGu56RX4XGwQoKlkE/WTTXi8/+KSDaHOr2BOq9b X-Received: by 2002:a17:90a:2e0b:b0:1c7:ef07:46f3 with SMTP id q11-20020a17090a2e0b00b001c7ef0746f3mr4513320pjd.124.1648239101777; Fri, 25 Mar 2022 13:11:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648239101; cv=none; d=google.com; s=arc-20160816; b=WPC9gPnzJVtw0MpgVRS4BoKAu4ttT8AcfRHgFZzA4Mi4d8H//8KbSqzBNLhc/cM9AJ ytbheI1xF4tdUaeiJs7CdfjtESygn98Enfz50RLv5VqGToDkYyyajff99vGi4jYV8uz8 wzMNJmtopKVyDGffqvjsd6ZtLgi8FR7zjlTYfyVHIBdgKQm1qfBi8jYGYCAIe7ReYma3 uWMMvzeZQbO34WeWgVQgunC0NgAWmdA2GOdRUlikHiN3p+clZNFZ+lYWWdBSh3kCGfBs 6s0WM7T/IKNPdk+MGMvJLehD1j63/hc2Gamrn5M8wSPvSo1PDcQwbobEjgzdImkGQ857 OHlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0xrqRiD/Zfu7He3VZql9A7q8sKTp+GYJiKJigMTjU34=; b=FkWiBRH3640pxlLq/caLbqYL/Kfr8IJReBdkSx2hfX7vwEuXHKooFkWeifjq0jnq7F DUkyUckAdXqVdyfeFT51hWl34VG88K1NrDzm+OfaN35edAu81F8J29NeZxqjhCdIVOfi lF1eyPsCMh1HBgiImiudHS1eJg8B2fpJ2wvZtvLx1oCfaWSeomrWsdJTwumQajs8N2GW 3E5QPam4Gqmdq81HowoyIMttnfnBU3/Pv+5Gl8ka4hn224hoWZKM2/M8dby75m/4EE8E Tz7BG3k75LWhOj8TNzGVKpjn5m5ymmLSP3Db+4b5L59zO70qtdM6C0Ijd/vET7tGslEt PYVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Dx3ZBMMw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id gk7-20020a17090b118700b001c681166e91si3399997pjb.137.2022.03.25.13.11.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 13:11:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Dx3ZBMMw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3C3E63B500A; Fri, 25 Mar 2022 11:54:15 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359719AbiCYPK4 (ORCPT + 99 others); Fri, 25 Mar 2022 11:10:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359711AbiCYPJZ (ORCPT ); Fri, 25 Mar 2022 11:09:25 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED5C2DA0BD; Fri, 25 Mar 2022 08:07:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 432C9B82902; Fri, 25 Mar 2022 15:07:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 777A3C340E9; Fri, 25 Mar 2022 15:07:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1648220833; bh=bfIWFb0ybUOQVhIIC+9w4qMZPczwc+SHltuVhsYoZ+M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dx3ZBMMwle+lwog4L1V77BhfadrOLVIlDTgFxSJ8I03RPK5gpjoqrPoGw+QJ+RFk+ ZEDdrcCivIOFmvnpudt8T6nHJQoXvRwldBs0lDKf6ihEKpflIcNuwykuphhwl6JfXV +es8uDDy80nB3dER+Cq2CoRJ0ysNKv9/B7fOrIyc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , =?UTF-8?q?=E8=B5=B5=E5=AD=90=E8=BD=A9?= , Stoyan Manolov , Jakub Kicinski Subject: [PATCH 4.19 06/20] llc: fix netdevice reference leaks in llc_ui_bind() Date: Fri, 25 Mar 2022 16:04:44 +0100 Message-Id: <20220325150417.195021457@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220325150417.010265747@linuxfoundation.org> References: <20220325150417.010265747@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Dumazet commit 764f4eb6846f5475f1244767d24d25dd86528a4a upstream. Whenever llc_ui_bind() and/or llc_ui_autobind() took a reference on a netdevice but subsequently fail, they must properly release their reference or risk the infamous message from unregister_netdevice() at device dismantle. unregister_netdevice: waiting for eth0 to become free. Usage count = 3 Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Eric Dumazet Reported-by: 赵子轩 Reported-by: Stoyan Manolov Link: https://lore.kernel.org/r/20220323004147.1990845-1-eric.dumazet@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/llc/af_llc.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/net/llc/af_llc.c +++ b/net/llc/af_llc.c @@ -311,6 +311,10 @@ static int llc_ui_autobind(struct socket sock_reset_flag(sk, SOCK_ZAPPED); rc = 0; out: + if (rc) { + dev_put(llc->dev); + llc->dev = NULL; + } return rc; } @@ -410,6 +414,10 @@ static int llc_ui_bind(struct socket *so out_put: llc_sap_put(sap); out: + if (rc) { + dev_put(llc->dev); + llc->dev = NULL; + } release_sock(sk); return rc; }