Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2201066pxb; Fri, 25 Mar 2022 12:56:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvvfKu4Z/9+ToUB11y7mvjY0KGDIjmuID7Dx9XnnvdthAm3Lp+LIjb5gAbyBp9oqAAAqXZ X-Received: by 2002:a05:6a00:1824:b0:4fa:8730:c986 with SMTP id y36-20020a056a00182400b004fa8730c986mr11730465pfa.43.1648238192225; Fri, 25 Mar 2022 12:56:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648238192; cv=none; d=google.com; s=arc-20160816; b=dVRzCniZBCuDOK0s8Uz8JV9w0YBvMO+/ZW0lT7X8oTRO4BAgDEVKvH0+pfGdhfEL1l 070X17WY0dWWKmAKDO0VJYVnXV9ar9VuNEN/uflyc+NHyhaHJR029761ZAwb9K4UQn5K ALhDvHQsyoAE5sGVfBFRBpRpyHQANeTicmVtp70F4XQONdpON+ZpDndSDevOH3tcrxiK lz/S5BP02Da2VKWGdG2SoMwy+BBoCFuPwtSLuabHOskF3YH4ywytkofZ2+xItcN46ghe kyFHi2UwuH1yQu7wvlam3HU9bCYRiUnofEWt/tuZ9CBKz9tQCQ/4H9GBbq/lR6atz+i6 WUew== 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=ZJWAWiefdksSWCKnZIsINWeHTp45f9IdCu/Ao1SQDQ4=; b=GIRtRmeSdWOJBLFjR+H1LJURxWKn4gxG/fAU/92no5wDhlA5vodeeJy5pm0KMNX4gR Ecz/nq+qaoRVO4FOgQz0KkMSu94PwtmqgGlIh+EHVRKwk07N9mGXK3FVVItOExtCuynt YqfYqF2zOMFe6AYiFoLzQy+ofrF6Aq8U2KLQhzeCfbXwC3116kxkkY3NVEOc2fY14/7o U4+J9hnBsRuAKSstTOPtcm0mvdIdzcaHplAdcuLemQpNl37iDzoA0x+483TIwUMRhRlK 1QUpnftyOhaXwf2xLAqoRb8JeupQsTz1uossnG2Ufxcn2O3HPUo+AT33nEzpbnqQIOcQ q2DA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=edbYk9Ax; 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 q2-20020a656242000000b003816043efacsi3133493pgv.417.2022.03.25.12.56.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 12:56:32 -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=edbYk9Ax; 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 C8A5A1A7702; Fri, 25 Mar 2022 11:45:26 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378230AbiCYPea (ORCPT + 99 others); Fri, 25 Mar 2022 11:34:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377966AbiCYPYp (ORCPT ); Fri, 25 Mar 2022 11:24:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 987BBEACAC; Fri, 25 Mar 2022 08:19:27 -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 dfw.source.kernel.org (Postfix) with ESMTPS id D127260AD0; Fri, 25 Mar 2022 15:19:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7912C340EE; Fri, 25 Mar 2022 15:19:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1648221566; bh=Y5pIaoEdFTFs9L/tDgexSz2P1Acwz8ZcBhY5B8L0/Ds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=edbYk9AxBbTTTzMvrC3gpODfVB4+14WNAoW2b0xt0/ujDKEyZuPFyrBgc/Fi19Jvm VNIF7lDcIp9Tnlmb4MxZTd/X1ZqPaHPTO4TVdRFf4pwUf/InRA4UsxxF6P0w0ajywN An7KLIbtu2N9eY3ed2M3Fv70pTjZq9CnCVgbEqyQ= 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 5.17 03/39] llc: fix netdevice reference leaks in llc_ui_bind() Date: Fri, 25 Mar 2022 16:14:18 +0100 Message-Id: <20220325150420.345250175@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220325150420.245733653@linuxfoundation.org> References: <20220325150420.245733653@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_track(llc->dev, &llc->dev_tracker); + llc->dev = NULL; + } return rc; } @@ -408,6 +412,10 @@ static int llc_ui_bind(struct socket *so out_put: llc_sap_put(sap); out: + if (rc) { + dev_put_track(llc->dev, &llc->dev_tracker); + llc->dev = NULL; + } release_sock(sk); return rc; }