Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp23057pxb; Fri, 15 Jan 2021 04:58:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzyWA1WJdHb041rUDm0yeXhX0dlygjG0KgqN3m/5p5kpr+jx/jzyuf8P7sOOgR8fFaKiMFR X-Received: by 2002:a05:6402:268a:: with SMTP id w10mr8411125edd.331.1610715497400; Fri, 15 Jan 2021 04:58:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610715497; cv=none; d=google.com; s=arc-20160816; b=oskaM3MzhRaKnBTfFlDLpwX/6yBz/TWfDxvhY3PjcP0k+aBwxlBbBzBc/w0DQG1gIO ktwdDzLxoPUP3Z+wTRbA38WTbOHBRLlqEYLhn6pptCz6hhuewek9RW1jUlVmQxFrF36M zwH97YK+Fj+UKyK4Jt/pB8rUt3ys/Kkry5NoxT5ZmYMLnN9nkrPWRUgHeVEC6tPe0PR3 YzzTnyXeRITWSM8O1WqGZ3NOFcb/8O7wR/j6+BSiaY+bkR2N5Bu7LgM2j3k/4RoCLmz+ xkcmD5Q94PZJKj+oMO0Ka6iZNgSt6mL+2h9e6r2HD76n3AcYPs/LF3Ociupe7aXZmUbg /rWA== 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=BzQUbjo1WKEZ5Hv85Cc5aTH53ZmagVSv+YjBI4dHxsg=; b=tZqmZRsXEer1Sy/O6r2YUB5dL5Ig9/Gy5CcEgbOB/rqYkivTq5L2AJ3nPlFaYLG09v mOztX50Kau6572mBIBATUmscGwM/765kGg1oPbd7gU8ehlnsVSvuQRuoDgt89HGZI6bc gGxqwdt9H3A/FKWO2mmffmMk7akMb1R8PIST2PwY2OdehxwamHUO7JsKSMIpjn4VYG3T eCk717CO+w/z4bve7TJyacoKIBNCMotQCZDOCNvXlGnCtRuwg0ZpK+wPqzuiuKR7xi4x tyLCXXXhqjZT0+hYBzJHTKrfqb9uw++Mir31v7TLTXqA6mh26Z9cHjBduLLW25YdheFc ADvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZVPUkXkP; 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 ca8si4102510edb.365.2021.01.15.04.57.52; Fri, 15 Jan 2021 04:58:17 -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=ZVPUkXkP; 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 S2387823AbhAOM4o (ORCPT + 99 others); Fri, 15 Jan 2021 07:56:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:41466 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732079AbhAOMef (ORCPT ); Fri, 15 Jan 2021 07:34:35 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 769672389B; Fri, 15 Jan 2021 12:33:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610714034; bh=l/nbjSbORLmGViyj3t9CdQfuvI62Sk4S7BDeyEKBqoQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZVPUkXkPQa4qCu6Kac0J3cryyfY+iVVgcOK4jeV6FQbRrP40g0ouKyWyqZtCxbvv7 W3jXMLs2H9dj5vis0vWiosc8xdG3qnUwNkyqKTYKVOoNMllm8jYcHE/qCbrRfFBi+0 jT555X8ndOOtTnO5X5COutUucXttayQPC1hPSEDs= 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.4 08/62] net: vlan: avoid leaks on register_vlan_dev() failures Date: Fri, 15 Jan 2021 13:27:30 +0100 Message-Id: <20210115121958.800341440@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210115121958.391610178@linuxfoundation.org> References: <20210115121958.391610178@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 @@ -280,7 +280,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; }