Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp18904pxb; Fri, 15 Jan 2021 04:50:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJyOWd8rWgFdn7Xs+10LAChsZuSHmsdmAmxA41bHQjGcW6csauvdrylbc6AzkdUosEfnXco7 X-Received: by 2002:a17:906:4544:: with SMTP id s4mr8533145ejq.366.1610715039354; Fri, 15 Jan 2021 04:50:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610715039; cv=none; d=google.com; s=arc-20160816; b=REUYKFQEwxcvI/AwkxKlrQtlgT2dUXXeOw0mb42tja/utCaSw+RDQy8plxYkA3ODkN jE+cdiDVmsOa+MN/kgixssjw9GLPvbwrwvJiw2KaMYZz27c9vwgpl0RV5YRs3wejMOeE KgJBFtFWAOAX/Fax6w20E2z1OncAMj/HIhcBfyAUOkE38Gcssb2nOur4UPbV4GxRbIHX PhRGZVm8G00d33qyU6dVWaJc5J0Fep+JJXIWTqu/UTWm6o+0SNCXFTwZio/ToXmuAn4v Q5r6cfB23WzyXsNlt8rwHihnudb/M9CZYdlgul4srRlmiSNCWy8x6vcsR1yOCBCwcG7w hSWw== 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=59iVuvtzo/zlyr6J/wW0ewUf6NktT63sl1mxRBlmP/s=; b=uPlU5HYnYkxa37yc5vhzEurW9Lh+PGb15MuPzm34owwyFTsyVQXuQ2cHrkZS1SxK9n 3VMjX7F0Ga7nFUlQ7Zi4swbplMY5PMBIrzSJEbSrA6iYuiDp7sWiSBR6Rl3zetwjT7kg VRU4t0gSD7T9cItMCQZrUAdPUexIMI/UnAikLdddXH83hJghHcEXADhjjcp97PUU3fwC 5WJ7LCPgznS02IBVSe3B8dwkdRh1raFejIR7Or5L53MsY93KNE8KETpj72vNp6AL2mKs 0Q2I2b4tyfIV0AUvAKm2Lxwa1vn5U16LlpInWumO05da6MuKM3lI2XvVdatTUniHo9ic 2LTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RGgRFtAm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t19si3801504eji.402.2021.01.15.04.50.15; Fri, 15 Jan 2021 04:50:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RGgRFtAm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387716AbhAOMtS (ORCPT + 99 others); Fri, 15 Jan 2021 07:49:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:42934 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727417AbhAOMgk (ORCPT ); Fri, 15 Jan 2021 07:36:40 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 53FC6221FA; Fri, 15 Jan 2021 12:36:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610714184; bh=rb/RAziuPJFotbLNfH5a2TLZPQNXLsb3cQjCx+een1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RGgRFtAm1azhUL84qffmZiytTkATe/iW4ws5AelhSmJRseM/9o+DebgR4c8PzLm7h I6nrpDOvJQh9wQRdo4ZxoDsyktznIrivbsK+RvrMPsLo+zThopvaZYlwF8/Q4vzRHn ATL9nY46tf0CCB2nLAxyQGnM7pPfJ8wuWJI93ZfI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jakub Kicinski , "David S. Miller" Subject: [PATCH 5.10 021/103] net: vlan: avoid leaks on register_vlan_dev() failures Date: Fri, 15 Jan 2021 13:27:14 +0100 Message-Id: <20210115122007.073696003@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210115122006.047132306@linuxfoundation.org> References: <20210115122006.047132306@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jakub Kicinski [ Upstream commit 55b7ab1178cbf41f979ff83236d3321ad35ed2ad ] VLAN checks for NETREG_UNINITIALIZED to distinguish between registration failure and unregistration in progress. Since commit cb626bf566eb ("net-sysfs: Fix reference count leak") registration failure may, however, result in NETREG_UNREGISTERED as well as NETREG_UNINITIALIZED. This fix is similer to cebb69754f37 ("rtnetlink: Fix memory(net_device) leak when ->newlink fails") Fixes: cb626bf566eb ("net-sysfs: Fix reference count leak") Signed-off-by: Jakub Kicinski Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/8021q/vlan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c @@ -284,7 +284,8 @@ static int register_vlan_device(struct n return 0; out_free_newdev: - if (new_dev->reg_state == NETREG_UNINITIALIZED) + if (new_dev->reg_state == NETREG_UNINITIALIZED || + new_dev->reg_state == NETREG_UNREGISTERED) free_netdev(new_dev); return err; }