Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3731751pxb; Mon, 4 Oct 2021 08:26:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfHmnuSzlAfJlPEMau+vyxqnX+VNc3gXbWvSiEt4WVwBieOHCTl7Rzyx4jDI2ZeL5VDjZ3 X-Received: by 2002:a17:902:a58b:b0:13e:cfb5:c086 with SMTP id az11-20020a170902a58b00b0013ecfb5c086mr304329plb.8.1633361181669; Mon, 04 Oct 2021 08:26:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633361181; cv=none; d=google.com; s=arc-20160816; b=Afch3Bv6h3hESCy4vwvlbjyv/uOxVCMMOTP3uQQGuj/nAq4o+0Wbh6JtmmyqlwaEFN PHnHcOE5d7SeBjBEhu1Di9W6pQms+2mwnJHwGnW0eMywSosdwPSidRCIiq9gb7IUt+Pd K32Gm+fjSVnFiMtTwIhQLaUSeRDKLnrvEKeVcMSlx8jdg+mBe3+KKgw+BTuLyZxLmEkZ BZp9XPSMe5gysCkPokdyQ76wKQc9Q8ii0Rm73aA7eWWrHiiYCuWcZX3U3SABmwg1m2Ef YAfysc1zVQyCZxczj1qfm+t4PuS/gaMbA7CQ7j+e5X6FofR/e8Szj33oqO0KnqCUFoZL NoVA== 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=OHnanuJJihB1COd713+iB3+XvK+m/YvpUhPsXyRe948=; b=Q8xQBiyuGP4xF0LP8ouQ/+IjN09Qw5GUSJzAwPvyc174v18UL69RHVzYqG5i+vpnwV eIq2NDJb/MFl8/pweUwi81av7s/KPhpvDNj2DxT5lkZpOGf+d37kao2EvnBez5yecE/3 YWD4W6KHs/AX05yDAT+AS6WfyRca9QILHdFfVaONKFtcS1n7A4iUKz9Fahmfx8DLtgiL NuiFf/dipsrzLboLPV2PBvqyOuvFqVq+uSMn5/d/58sC67UIbc/r9RDckCh55c+dRT6m u7oVXXNvh774MO5aDCL7nclh+aF6/qfRArP1NHT/BYLOza6lraQGqVHg8/5Acu88jUUE doYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WRMlv67m; 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 q18si1759660pjp.61.2021.10.04.08.26.08; Mon, 04 Oct 2021 08:26:21 -0700 (PDT) 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=WRMlv67m; 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 S235709AbhJDNPG (ORCPT + 99 others); Mon, 4 Oct 2021 09:15:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:46566 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236086AbhJDNNK (ORCPT ); Mon, 4 Oct 2021 09:13:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E710461BA4; Mon, 4 Oct 2021 13:05:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633352707; bh=eyC0Tzv53FFFU/5eHMqYw7yMEYbE1QpsRWtofhlR+C8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WRMlv67m1Pab/YrF/KPVVklP6ikEzPLK8OAujV3dSSQVXqJLVfwCTXTgay0RGepQ5 NEIvnBPdedtWyMp6ZroSF87C13KSnZep6X2dl69PHEcI3EoEHACzOwChKTWNHfaBLH 7eo9jjJW1YdjpTb/hJH633r/A6rqoicFmpUe+BmE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oliver Neukum , "David S. Miller" , Ovidiu Panait Subject: [PATCH 4.19 88/95] hso: fix bailout in error case of probe Date: Mon, 4 Oct 2021 14:52:58 +0200 Message-Id: <20211004125036.456344463@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125033.572932188@linuxfoundation.org> References: <20211004125033.572932188@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: Oliver Neukum commit 5fcfb6d0bfcda17f0d0656e4e5b3710af2bbaae5 upstream. The driver tries to reuse code for disconnect in case of a failed probe. If resources need to be freed after an error in probe, the netdev must not be freed because it has never been registered. Fix it by telling the helper which path we are in. Signed-off-by: Oliver Neukum Signed-off-by: David S. Miller Signed-off-by: Ovidiu Panait Signed-off-by: Greg Kroah-Hartman --- drivers/net/usb/hso.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c @@ -2368,7 +2368,7 @@ static int remove_net_device(struct hso_ } /* Frees our network device */ -static void hso_free_net_device(struct hso_device *hso_dev) +static void hso_free_net_device(struct hso_device *hso_dev, bool bailout) { int i; struct hso_net *hso_net = dev2net(hso_dev); @@ -2391,7 +2391,7 @@ static void hso_free_net_device(struct h kfree(hso_net->mux_bulk_tx_buf); hso_net->mux_bulk_tx_buf = NULL; - if (hso_net->net) + if (hso_net->net && !bailout) free_netdev(hso_net->net); kfree(hso_dev); @@ -2567,7 +2567,7 @@ static struct hso_device *hso_create_net return hso_dev; exit: - hso_free_net_device(hso_dev); + hso_free_net_device(hso_dev, true); return NULL; } @@ -3130,7 +3130,7 @@ static void hso_free_interface(struct us rfkill_unregister(rfk); rfkill_destroy(rfk); } - hso_free_net_device(network_table[i]); + hso_free_net_device(network_table[i], false); } } }