Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6550331ybx; Mon, 11 Nov 2019 10:47:57 -0800 (PST) X-Google-Smtp-Source: APXvYqx+CvEYjtR0fMMLraYSgb3J+FbsvVOMIwwarwfRuYP/ttTLj1BAtoNm9jn19mvJojbzlaVH X-Received: by 2002:a17:906:da1d:: with SMTP id fi29mr23762702ejb.26.1573498077352; Mon, 11 Nov 2019 10:47:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573498077; cv=none; d=google.com; s=arc-20160816; b=kXYD0gnjNKI5SRL0J0YxHtwthQ9SXxYo6RN/JFSIAazsV7kJYj566BIXeIYL08Qa2O fNapIiPc1ZDvmc7wKW1Zo39oe3g5kQBXEf49PGanG8SOsUJT73A+4guU7bSOeCKFQOos ve41EFHkytVSsBYxEM8E31YVDm9oT/UfFTNxB+OLHgxW0eBT/5e9u997dNHf5eOzbYRA NvHfcRM8obVVggVcz//C+i2TEFtk2yUwELRkAXW/Q1ZWOgqrbk614j3hwEA5EJW1KnSe k/8e1gkWLR6fVG5P3N1B30Xk7NYIoRj5RGMYc/os26zhSNeaOswvtwBJnAoYSJ3PeAgx y3FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=o4SVfpVE/cJZycZDe+TgHnBa1saCtXNYN/eMrh5lC+s=; b=BwWYsp/0SSzO+CTAFKJS4gEbQihfaQ/NU5DOO+QqAqREqv4w1O5T/fsWJs0IkS6K5H BBqTFvZf8+hoeJYkNRMAw0bmu+RAgKe4h+p78PkwiOzrlciSi0Y+XJQyk9oH/39g7goI q/4vfjI9xgrhDq0nTGIQjtSHdDQ/z7sJyypA8s0sfpK4ZVSPmsAvrUDcqvkDMygtabVt npuAnMu93HxYUXAhqa6BoGdHoBPGpLxig/YWG8wSWagVoSlrTE60r3G6pHXA3VJNb/ME jARcpibFFgvREJzlgXGvKpeQ/mL7kROOEZVnVd0wPUy+e0RhAVwM8z0VNL1u6GK4NdN/ Qy+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tHWchNXD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v12si12129187edf.71.2019.11.11.10.47.33; Mon, 11 Nov 2019 10:47:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tHWchNXD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729987AbfKKSqV (ORCPT + 99 others); Mon, 11 Nov 2019 13:46:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:38756 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729984AbfKKSqS (ORCPT ); Mon, 11 Nov 2019 13:46:18 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 52E3921655; Mon, 11 Nov 2019 18:46:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573497977; bh=Cy38CBA9w5CE8lj9VSGlg26w/40zREJw3/30CScJPXw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tHWchNXDT3MTFeHcYATqeHfYmNKPa95BdsRBIBUyImhwEJIaBNI7zL1dCr1XxN9bn gT/zYdBip8QmyRD3iA3vjI+5sZOIb3cjI4huKjeQ4n04o0JbVkNVzzP9VzEHttsClN 2Hvu3vJh7yZgh5rZ9vLfTfzL8oxS0n6GF+zfBvLE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Haiyang Zhang , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 112/125] hv_netvsc: Fix error handling in netvsc_attach() Date: Mon, 11 Nov 2019 19:29:11 +0100 Message-Id: <20191111181454.792993510@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191111181438.945353076@linuxfoundation.org> References: <20191111181438.945353076@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Haiyang Zhang [ Upstream commit 719b85c336ed35565d0f3982269d6f684087bb00 ] If rndis_filter_open() fails, we need to remove the rndis device created in earlier steps, before returning an error code. Otherwise, the retry of netvsc_attach() from its callers will fail and hang. Fixes: 7b2ee50c0cd5 ("hv_netvsc: common detach logic") Signed-off-by: Haiyang Zhang Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/hyperv/netvsc_drv.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 6f6c0dbd91fc8..b7a71c203aa37 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -993,7 +993,7 @@ static int netvsc_attach(struct net_device *ndev, if (netif_running(ndev)) { ret = rndis_filter_open(nvdev); if (ret) - return ret; + goto err; rdev = nvdev->extension; if (!rdev->link_state) @@ -1001,6 +1001,13 @@ static int netvsc_attach(struct net_device *ndev, } return 0; + +err: + netif_device_detach(ndev); + + rndis_filter_device_remove(hdev, nvdev); + + return ret; } static int netvsc_set_channels(struct net_device *net, -- 2.20.1