🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #10240

[PATCH] net: usb: hso: free an unused shared interrupt state on probe failure

#10240
From: Wentao Liang
Date: Tue, 03 Nov 2026 10:29
88 lines
11106 bytes
hso_probe() allocates the shared interrupt state with
hso_create_shared_int() for a multiplexed interface and then creates one
muxed serial device per port advertised by the device. A muxed serial
device takes ownership of the shared interrupt state by incrementing its
ref_count, and hso_free_serial_device() releases the state together with
the last reference.

There are two paths where the state is allocated but no serial device
ever takes a reference to it: the port mask read from the device contains
no port that can be muxed (including a port mask of zero), and the
creation of the first muxed serial device fails. In both cases
hso_probe() leaves through a path that only frees the registered serial
and network devices, so the URB, the buffer, the mutex and the state
itself are leaked.

Release the state in both places when no serial device took it over.
hso_free_shared_int() still has to be called with the state's mutex held,
so add a small helper which takes the lock first.

Fixes: 72dc1c096c70 ("HSO: add option hso driver")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/net/usb/hso.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index 71caa3764b23..818444830072 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -2736,6 +2736,13 @@ static void hso_free_shared_int(struct hso_shared_int *mux)
 	kfree(mux);
 }
 
+/* Release a shared interrupt state which no muxed serial device took over */
+static void hso_free_unused_shared_int(struct hso_shared_int *shared_int)
+{
+	mutex_lock(&shared_int->shared_int_lock);
+	hso_free_shared_int(shared_int);
+}
+
 static
 struct hso_shared_int *hso_create_shared_int(struct usb_interface *interface)
 {
@@ -2853,8 +2860,9 @@ static int hso_probe(struct usb_interface *interface,
 	int mux, i, if_num, port_spec;
 	unsigned char port_mask;
 	struct hso_device *hso_dev = NULL;
-	struct hso_shared_int *shared_int;
+	struct hso_shared_int *shared_int = NULL;
 	struct hso_device *tmp_dev = NULL;
+	int mux_count = 0;
 
 	if (interface->cur_altsetting->desc.bInterfaceClass != 0xFF) {
 		dev_err(&interface->dev, "Not our interface\n");
@@ -2912,11 +2920,16 @@ static int hso_probe(struct usb_interface *interface,
 						interface, i, shared_int);
 				if (!hso_dev)
 					goto exit;
+				mux_count++;
 			}
 		}
 
 		if (tmp_dev)
 			hso_dev = tmp_dev;
+
+		/* No muxed port took over the shared interrupt state */
+		if (!mux_count)
+			hso_free_unused_shared_int(shared_int);
 		break;
 
 	case HSO_INTF_BULK:
@@ -2943,6 +2956,11 @@ static int hso_probe(struct usb_interface *interface,
 	return 0;
 exit:
 	hso_free_interface(interface);
+
+	/* No muxed port took over the shared interrupt state */
+	if (shared_int && !mux_count)
+		hso_free_unused_shared_int(shared_int);
+
 	return -ENODEV;
 }
 
-- 
2.34.1
Technical Details
Message-ID: <20261103102900.1340894-1-vulab@iscas.ac.cn>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-355437-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-355437-linux-kernel-netdev=dewy.ru
From: vulab@iscas.ac.cn (Wentao Liang)
Newsgroups: linux.kernel.netdev
Subject: [PATCH] net: usb: hso: free an unused shared interrupt state on probe failure
Date: Tue,  3 Nov 2026 10:29:00 +0000
Organization: Usenet Network
Message-ID: <20261103102900.1340894-1-vulab@iscas.ac.cn>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3148396"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:gp/UBrGi19dsfJcJOxraeYqSxg4= sha256:ekezCvhNphHPQSpYla77lGrw6Ml7GPBs8DOu+lBHObI=
	sha1:NCJ3BEVsECT8SUP4vrDTPc1W6A0= sha256:jKKxi3JKuhin2rxP3TJ73bfnmtS8eo64yn0+qFR9BeI=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 3D72111280E; Tue,  3 Nov 2026 14:05:41 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: 0.507
X-Spam-Status: No, score=0.507 tagged_above=-9999 required=6.31
	tests=[HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_SBL_CSS=3.558, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=no autolearn_force=no
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id yoe99sR3U3M6;
	Tue,  3 Nov 2026 14:05:37 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-355437-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=iscas.ac.cn
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 56FDF1127BE; Tue,  3 Nov 2026 14:05:32 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id C0DC961132D; Tue,  3 Nov 2026 10:38:11 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail;
	t=1793701739;
	b=P9Ql4pJ+wVmPs/1ZJhkaywDFeDIj9vjBXtGdcuF0nZNTnH0Eth5zfqjY9r/tUkRX0hWy
	 AT1SbQS6CzPEXypaDi687oQPi2aEfls0TbDBIOjeNDx9kG8b7XZZON8XiDaddQ6cKu8e9
	 So9WIIbYsMwA0DPMG1a5K64Z3tZXLnenCtXqt2WJjC2ZNv31ezit+KxhW2jscxI3j1ytP
	 d9YbfPReTiOub1iCnYrg3agvMjcBVJ2SftoPuai2rCnRHsxa16N9EPEYYl1Qwwspa6g3i
	 oSXjz4ynnUERIhNz9mOHj+3U/6CSn2lMx4sLHjyRyZMRXyBCHNpSK55d9/JhdDwih9A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793701739;
	h=X-Original-To:Received:DMARC-Filter:Received:From:To:Cc:Subject:Date:
	 Message-Id:X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding:X-CM-TRANSID:X-Coremail-Antispam:
	 X-CM-SenderInfo;
	bh=atR9w/LIKXlCxoZMtunWQfcgxsIkELEPvu7ajRcHDaM=;
	b=nnDqrNn3TwvJjeZo73FoYwFsIh4PSs4DGL5cTOrY6SgzwYXzsQJhMDyVJXb1/17p6q0i
	 owzW842U82JXop+hUKwBgVEUa69T1430izBNCKvw74SmInf/NmkhjnY6TQWTVkJ/Hc3mz
	 yGmwy4Dx7Lt5itPPnFwTn0eVG/kCeyCvnGbbIhzPujvPiNy0Bs9ru+nYqSTORsIM8xlV+
	 P1yvkCbu8h+pDtc8e4jSFrteCFzQM+jk45b99IawNPrMK3QJYwsDxMgFhaT/d7Loco2NN
	 qZsQYz7ISBOOqG4UL8sCyglPa4yhNO0+3q4add1BqKFN4weO/0WIK1NX8vjS0f8fMZA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dmarc=none header.from=iscas.ac.cn;
	spf=pass smtp.mailfrom=iscas.ac.cn;
	arc=fail smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 191076075BD0;
	Tue,  3 Nov 2026 10:28:59 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=159.226.251.81
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793701738;
	b=CMl2o2WvnsHE/Ic1hfhUCi9jRi4LZIW2IEVvP1GYM5SfhFzuWknQ77eozF5IprAiEw1o
	 5B+NmQ4x2m5W8VoijAMi/J74mv1lWALXMfvar5Z4lvIFcdAOQkn+JYitcvHMDIfa3TEyF
	 TGY+EdoanP3/F9R5t6evfrIxy8E0RcsM0BrcvooJgx/ga+1OjVbYWxfw2Q5RypMWeoJex
	 z6DTRg0PoxsR2Ot3w1rHT0cUAnNep8yrRCPTC5kEYXIr/aWWl4BbrSc2EaadhYexC+vNO
	 YPc+o5yFuztCABLbO3iKRu+AtFHod3EpavVZUnaCtKI2k8PiIen+OuHXPIKzUMh29hw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793701738;
	h=DMARC-Filter:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer:
	 MIME-Version:Content-Transfer-Encoding:X-CM-TRANSID:
	 X-Coremail-Antispam:X-Originating-IP:X-CM-SenderInfo;
	bh=atR9w/LIKXlCxoZMtunWQfcgxsIkELEPvu7ajRcHDaM=;
	b=rPiXixtM73A0bAj2F4JIDgZrAb6c+0yBFvqpPuSH6SGqPdCam9nJD7MkL3sclrF4EPvK
	 mHiwi+14zpSH4yoxNQ6ZGR1sAAusbScIbtzMeeRCH4LaVV1QvkthFMZGL25739laCNRXY
	 SXKR/cZ4XJHPcWwSvZ0LO2tox8T3VCAy5sdPABA08UCH+ANsR6sWmVBZf9SW/eIvvhTmz
	 lbzhMOW1JZfa2ZOa6bxa5dyGiPyVvgYsEQzH/sBMSjJdF0JErC+khxjGPLo9o3AR4Xr8E
	 YggU15KKU627SuKSCwQ0Y2zLvN0PXNnE1NxABdrlEOLCmXlX6MIdRp29zk0bcSUDLNg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=iscas.ac.cn;
	spf=pass smtp.mailfrom=iscas.ac.cn;
	arc=none smtp.remote-ip=159.226.251.81
X-Received: from cstnet.cn (smtp81.cstnet.cn [159.226.251.81])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 243CA60752F0;
	Tue,  3 Nov 2026 10:28:56 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 243CA60752F0
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iscas.ac.cn
X-Received: from dfae2b116770.home.arpa (unknown [36.110.52.2])
	by APP-03 (Coremail) with SMTP id rQCowAAnN5hjt+lq0qk7AA--.49100S2;
	Tue, 03 Nov 2026 18:28:51 +0800 (CST)
X-Cc: linux-usb@vger.kernel.org,
	netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Wentao Liang <vulab@iscas.ac.cn>,
	stable@vger.kernel.org
X-Mailer: git-send-email 2.34.1
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org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