Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2128820pxb; Fri, 25 Mar 2022 11:35:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbq/qDFisbo371HQKzWpzbfNo96LgUBeS441qRkeBJQb1WZ5pRxfglp9MSGO6Oz9i2sxEP X-Received: by 2002:a17:902:8497:b0:154:9282:bc01 with SMTP id c23-20020a170902849700b001549282bc01mr13279033plo.33.1648233327720; Fri, 25 Mar 2022 11:35:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648233327; cv=none; d=google.com; s=arc-20160816; b=PU/fEKaMqD+Fk/x1N2whaflmzrjAVG+mSqBrCK28Hgi18a2kNzAO0wKjudl902DvtO 0i4upd++hLKwyFadLajOIV8iBHYjURfpizL3+YjoxPEb5tMyv6Q0JFW0Glk/Em63FiEd G1Q4JIVF891bQgZ+5+x/ZHlG9upf7zwEpXHjL9TnGTyF7ywhre+H4RJv6B0Hehbjzd56 CIFt6lHjIHqBfX2SfC6B65fIjoY0GO/awcKV9+mh0P9rURBekrI4TV+B4wNTRml0myGY a1y7+MN8ZpmJtDxBPhPHg2ch4mTdyMJ+KuBmneyl57Y112yDClxzR+lS3x6YCuNffe9E HQ3Q== 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=fkZNWfRIyyMymX3BI/6SiFW62iI/2S7ytFNepuyyVMo=; b=Ett7zugJLDHDbppI/YWUtRhXSoCduwh+tdmNNzrW4Pu/5QESH4RinOiLafYRRHrzN5 KqkIxmsgZtPLXCrJPnm8x3XJVTZAbpfR6UdRi/DAvUObTI0zkMq6rRvyybdRzcBWeYqx P0QFh6huMbaTyLk5YldIqeAWhnRLY4JlPpc3X6mvHS6BVNyYBw8DTbq/nTE1FxR6Sdbl WhhcGAHxKVm1iHybdYFwo/ZUwfVGjWN5SPbREpVi29uGHxgftbChmODWcd55tjMZdRpN 5on3x8hRQb5rpzvek3qRITKAFlPA/QEv1Q04NmNUP06rC6sdqmXjBPlrrWHG3Cwq9YJm uT6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fckkzrhz; 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-20020a170902eb8200b00153b2d1656dsi2803453plg.373.2022.03.25.11.35.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 11:35:27 -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=fckkzrhz; 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 out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0BFB618DAB7; Fri, 25 Mar 2022 10:55:16 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359564AbiCYPHk (ORCPT + 99 others); Fri, 25 Mar 2022 11:07:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359549AbiCYPG6 (ORCPT ); Fri, 25 Mar 2022 11:06:58 -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 3F835D95E8; Fri, 25 Mar 2022 08:05: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 dfw.source.kernel.org (Postfix) with ESMTPS id A2B3861BED; Fri, 25 Mar 2022 15:05:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C3B1C340E9; Fri, 25 Mar 2022 15:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1648220714; bh=KnJzV38gB/o19Hw+TyuQ8Vb0GO74g5pqUypXT2furxU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fckkzrhzhTofjjRqtoJ84yQR/Bf0Oe25F7t9XryOSS7i9KYCDwL9gsKtj4fGGgkTj eS+BYWHzKqeIY7Gs/UzVz660sVGVNokY9hmL6gUsx7a8MRVGtBBBEPFpSD2ubbVZgx phtlUafub/lJPRxvBFEYG5MrEIfpu+TLIP6zYtcg= 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.9 04/14] llc: fix netdevice reference leaks in llc_ui_bind() Date: Fri, 25 Mar 2022 16:04:32 +0100 Message-Id: <20220325150415.827452295@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220325150415.694544076@linuxfoundation.org> References: <20220325150415.694544076@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 @@ -309,6 +309,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; } @@ -408,6 +412,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; }