From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out203-205-221-239.mail.qq.com (out203-205-221-239.mail.qq.com [203.205.221.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5096384CED for ; Wed, 17 Jun 2026 08:37:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.205.221.239 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781685461; cv=none; b=cNVWiK0VJPzNcxO6mcoG9cUey3xyZuOMe3SM4LPz70TiAGY3eF7OyceJzYdHVvufvXSTmkenq4TlVhC68E8TXQS5CdjPg61bWPnFbUuVh9Zf47px0xjVM2m/L/Lug5mslxDvqPI5b2SA3vakfKGIw9+i0j2WzsZJdYz0NnOi1Eo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781685461; c=relaxed/simple; bh=O7HZjWCt18m6PSBYAtjgnd02COMCQcAQzxwmonUKx2M=; h=Message-ID:From:To:Cc:Subject:Date:MIME-Version; b=RCHPNGxFnNnoMb+ZlJ8VyxfPyBotnVmQuyQzNLkROAtPscFKGC+O7LSddwQuo8w+MD/juWJNl3wYbWCLiqsAM3gReJyWOl/+UAS4FQCvrIYdIC96NAUtZWI/0jj1vWYGdvgHSrB+M31rMWhkMTzkQxHsN28kF+rwTaEgBIulFBA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foxmail.com; spf=pass smtp.mailfrom=foxmail.com; dkim=pass (1024-bit key) header.d=foxmail.com header.i=@foxmail.com header.b=niIwYISl; arc=none smtp.client-ip=203.205.221.239 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foxmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=foxmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=foxmail.com header.i=@foxmail.com header.b="niIwYISl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1781685451; bh=ZL6MZws8hpFpdAdta2hb/uWnkygCZQKxs3v2xBC/rLI=; h=From:To:Cc:Subject:Date; b=niIwYISlKYJGfkba+VDk3Wk6/c39eIszDFcLNMXNgzCBAp/zDqYWJjYTXWiUCKaWG v+mF11SRmh3/Enb+5xZFHaZshK79j3xWdrk6p63Rg76zeu2yn9V8hWoJjeZmEuTANK 4uq0jvr/VU2PR8yXsXrYKHyLW316nj5evNCvNC3Q= Received: from localhost.localdomain ([116.128.244.169]) by newxmesmtplogicsvrsza63-0.qq.com (NewEsmtp) with SMTP id 95D2D60D; Wed, 17 Jun 2026 16:37:29 +0800 X-QQ-mid: xmsmtpt1781685449txfyd4ag2 Message-ID: X-QQ-XMAILINFO: NbgegmlEc3JunLHck7/HAqm04Ab2CgTNY6BM6txkyxJ0lm2biVQgNkccq3sf9C J95/DAyI4+EI/WfbgjOByrA/b8FF7STKj+h8CHWFXIWZU+uGRM0xGIFGXQNL1Yvw3GWVcTwX4s7T 8vKXcUzhUq8PMSGoTbwyEs75bm0OMAOm3YU+UP2TrI2PEStAVTN+Dmvr24W7iSJmSwhZ5WluTONC cq3HUSBUildITmJGmuWIA3KMzDY7/aNYAio0iQKfFg6C0iqPYH3IOcwOuO53Nj4dyPg9ZAHCdvHr GJykKmYOqQBCQaBbXTdoaQWum4VPecxT+746/1QSeN/TSzsqp8f7xGCnkeEBuTgk8qtQsVeb2TPR Zz2h3slk+I3NdbypJWwINLkz5T6xnUSEKJwYkE7nBl7SZUMvW2Cl41adCA0kiAJDSpLOAqhOLOTl BrJqz9+Wjr4jWNmzQ08SU62t4nWJG2DzRt4cmpySI/jVPGjeCoTUZqTQ9S2GeUiDtOT4EFWPR9tS G2GEuVVa4aj0ux87VltCXtUKDW4jQ3XZ2pdWMcFLtCdaogwSriaiOhRzJ9GI68MqlTuH6uV8jS6s 6UK3c3e2JcDMf4H4uRArwquH41DSGVa7lPx1Dtc+UpolAUzen6u2pU9jih9nh9ierzcoQPYCMFZP 43E7rSn9Cl8iCJC6a7vqU170hHML5TE0QaPXFS07vVI9p8WXzXwGoXeLEy3qm+K3IK66sWyPynNV jK1Viy8POc+3I3LA5wnE55X9OP46pIEafJWvmD/scw1b93vuUCqzfxeIErB0VSNl0g/QRFxx25Fw dM/ekBDxbKXiFiGTTSggNQxGDudEjAz/+1P9oB38dbxypnx5FHBJ7cKlRJkTPQIfa05C9z3EWmME oF7aaTqvuvqt+Zp20cYNZcGlL4WwK4ZFE9B5FkfZNMU4ENI2u39eRyqKppV9sK9x2kZYRcE5PIi7 JNGHP23slNqFwLRfHZ6oIx167UyeUL0M3LkWZ1TCJEXA7+WrnEPo9ivvRnxQvj3th9C1BcMqIX8F wYnSAkcirgD49WxyVGGnDw112X0p/bztJ/5GEmScDYiQb8YGyl X-QQ-XMRINFO: OWPUhxQsoeAVwkVaQIEGSKwwgKCxK/fD5g== From: Zhao Dongdong To: parthiban.veerasooran@microchip.com, christian.gromm@microchip.com Cc: linux-kernel@vger.kernel.org, Zhao Dongdong Subject: [PATCH] most: usb: fix memory leak on most_register_interface failure Date: Wed, 17 Jun 2026 16:37:25 +0800 X-OQ-MSGID: <20260617083725.405222-1-winter91@foxmail.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Zhao Dongdong In hdm_probe(), when most_register_interface() fails, the function returns the error code directly without freeing the previously allocated memory (mdev->busy_urbs, mdev->ep_address, mdev->cap, mdev->conf, and mdev). Add an err_free_busy_urbs label and use goto to properly clean up all allocated resources on failure. Fixes: 97a6f772f36b ("drivers: most: add USB adapter driver") Signed-off-by: Zhao Dongdong --- drivers/most/most_usb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/most/most_usb.c b/drivers/most/most_usb.c index 6437733afee0..c20901e1ce6c 100644 --- a/drivers/most/most_usb.c +++ b/drivers/most/most_usb.c @@ -1056,7 +1056,7 @@ hdm_probe(struct usb_interface *interface, const struct usb_device_id *id) ret = most_register_interface(&mdev->iface); if (ret) - return ret; + goto err_free_busy_urbs; mutex_lock(&mdev->io_mutex); if (le16_to_cpu(usb_dev->descriptor.idProduct) == USB_DEV_ID_OS81118 || @@ -1084,6 +1084,8 @@ hdm_probe(struct usb_interface *interface, const struct usb_device_id *id) mutex_unlock(&mdev->io_mutex); return 0; +err_free_busy_urbs: + kfree(mdev->busy_urbs); err_free_ep_address: kfree(mdev->ep_address); err_free_cap: -- 2.25.1