Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp26297pxb; Fri, 15 Jan 2021 05:02:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJxZdDqvtQ7F1IyAXQcPUBWSxkDizdkv5jzCxyG9Z0gliEDnTGi9W+JdZWEveZFOKNAX9jK5 X-Received: by 2002:a17:906:ae41:: with SMTP id lf1mr8846399ejb.369.1610715769850; Fri, 15 Jan 2021 05:02:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610715769; cv=none; d=google.com; s=arc-20160816; b=QIra9x4b9208bh/rAACO/s9Vhr8LAySXZWIv5hs/oW2QQ/iLiS6eD6+GJsl5O0l26f 6fWnFRREg7VpsxJG9nkFbU9y3X4hBa3WWKto3Qqddf52w8zZpwgoBl25101NjZgEqyZa LZOzz+LFPMMhXZ2vJJc9jkOEAGMJMqTCiD8eQx+U8+a6iw2Hsbl1qpaMmZ97k2uyxET5 x+zaYNfwARqWV+iLU7hlJVn1mNt7NettfpKo76M3FUkG062BdmN+o5r3FCRIVh+FFVl3 +NRa0VmbhA5Dq7Qot8XuGZuknQwlXULvlNBpVrocp81h1IeeFrV4Ht++WBOdMMJ4Nkft noww== 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=Prpu7Ct4QooRazhCWut5IV9/81y6kZ5+F4CO3Jn4LU0=; b=ylBkg7Cd/EXeObF5tyUBIsqViQHOtSmC7Kn0xm2HB+O1G4pFs5HsRBwKE/m3sYv4Ap /VNxI/5MmI0VWO5VMraBBOzoQeBuX0gOUYuOsl3O1VDLfBwvi+haGEB2XDx/3zhnZff3 I1pOHHT9vnUNvEI5q7ufqjYFvhG3oIMmEBSRwDWClNF+J+OKFKs73Xs58bbuChBAqHEG f5S1pPSPKZ4NZdhY9dy4plVvIVZqoZDS3dL2Fw5XGU2ZW6MnxVKFsubVLCBQ+IWm/4bF +2r1trP9HDABbJuZ28fhaESrZLOndg6n+15mpnq88dmtDoKpSCxBPqq3tsylpv7IWP5a jk6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rSkwo2gt; 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 l6si3846494edq.274.2021.01.15.05.02.23; Fri, 15 Jan 2021 05:02:49 -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=rSkwo2gt; 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 S2387422AbhAONBz (ORCPT + 99 others); Fri, 15 Jan 2021 08:01:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:39426 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733041AbhAOMc6 (ORCPT ); Fri, 15 Jan 2021 07:32:58 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2433A23884; Fri, 15 Jan 2021 12:32:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610713962; bh=/6OtgpkAcLwhpPaznxOQq4fJsVnYKg8lwYWNpIgt+b4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rSkwo2gtCY4iH4supeAAhzEoD56ph6f/6VCHphc92c74GEmJOFqNf8Wg4BH7l2DwB zB2+t/QVEHGIh1SEGNHef6JIhn2U4SHJKluWKTkAGM52ggboeyvEW96+OYrAiV8KTO TwbsXwfwVIiayMnHqu9LSNr3Wq4Z/C5s4GJg1S+4= 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 4.19 05/43] net: vlan: avoid leaks on register_vlan_dev() failures Date: Fri, 15 Jan 2021 13:27:35 +0100 Message-Id: <20210115121957.312655457@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210115121957.037407908@linuxfoundation.org> References: <20210115121957.037407908@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 @@ -277,7 +277,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; }