Article View: linux.kernel.netdev
Article #26025[PATCH net-next 21/23] can: peak_usb: pass the dev_num argument of PCAN-USB Pro GETDEVID
From: Marc Kleine-Budde
Date: Wed, 02 Dec 2026 23:04
Date: Wed, 02 Dec 2026 23:04
50 lines
12190 bytes
12190 bytes
From: Stéphane Grosjean <s.grosjean@peak-system.fr>
pcan_usb_pro_get_can_channel_id() builds its GETDEVID record with
pcan_msg_add_rec(), passing only the channel index. However,
pcan_msg_add_rec() handles GETDEVID together with SETBTR and SETDEVID,
and also reads a second argument with va_arg(), to fill the dev_num
field of the record. Reading this missing argument is undefined
behavior: in practice, whatever value is left in the corresponding
register or stack slot is written to the request in dev->cmd_buf.
This value is sent to the device with each GETDEVID request. Moreover,
peak_usb_disconnect() clears PCAN_USB_STATE_CONNECTED before it
unregisters the netdevs, and once it is cleared,
pcan_usb_pro_send_cmd() and pcan_usb_pro_wait_rsp() return success
without any USB transfer. pcan_usb_pro_get_can_channel_id() then
returns the dev_num field of the request as the CAN channel ID, so an
ETHTOOL_GEEPROM request handled in this window makes
peak_usb_get_eeprom() copy that value to userspace, and cache it in
dev->can_channel_id.
Pass 0 as dev_num, so that the request is fully defined, and a null ID
is returned in that case.
Found by Sashiko AI review.
Fixes: d8a199355f8f ("can: usb: PEAK-System Technik PCAN-USB Pro specific part")
Cc: stable@vger.kernel.org
Signed-off-by: Stéphane Grosjean <s.grosjean@peak-system.fr>
Link: https://patch.msgid.link/20261126-canfd_check_channel_idx-v9-12-abe0099b4585@peak-system.fr
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/usb/peak_usb/pcan_usb_pro.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
index 840658723648..0d014f4c08a7 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
@@ -435,7 +435,7 @@ static int pcan_usb_pro_get_can_channel_id(struct peak_usb_device *dev,
u8 *pc;
pc = pcan_msg_init_empty(&um, dev->cmd_buf, PCAN_USB_MAX_CMD_LEN);
- pcan_msg_add_rec(&um, PCAN_USBPRO_GETDEVID, dev->ctrl_idx);
+ pcan_msg_add_rec(&um, PCAN_USBPRO_GETDEVID, dev->ctrl_idx, 0);
err = pcan_usb_pro_send_cmd(dev, &um);
if (err)
--
2.53.0
Technical Details
Message-ID:
<20261202230853.2665144-22-mkl@pengutronix.de>Path:
mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376121-linux-kernel-netdev=dewy.ruReferences:
<20261202230853.2665144-1-mkl@pengutronix.de>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376121-linux-kernel-netdev=dewy.ru From: mkl@pengutronix.de (Marc Kleine-Budde) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next 21/23] can: peak_usb: pass the dev_num argument of PCAN-USB Pro GETDEVID Date: Thu, 3 Dec 2026 00:04:46 +0100 Organization: Usenet Network Message-ID: <20261202230853.2665144-22-mkl@pengutronix.de> References: <20261202230853.2665144-1-mkl@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2085092"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:czj6NXS35OmjuZsD+ypNAj2IxJw= sha256:HwP334pAcSOhd+Ot1QVu7JnL3lgrdHHQMGRlRWdJhMI= sha1:2Vx7xq7l11qOG50yU0SSAEoJdOM= sha256:J+IG4s+tfjy+4X2Fzn/26LQ2RFkKoI1tHaFKcdk3+0g= 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 3994C11778D; Thu, 3 Dec 2026 02:10:53 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.05 X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=pengutronix.de 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 Kx9cvkDW2WYh; Thu, 3 Dec 2026 02:10:50 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-376121-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=pengutronix.de X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id ACD2711777B; Thu, 3 Dec 2026 02:10:41 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 1CBC328D14; Wed, 2 Dec 2026 23:10:39 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796253038; b=jcu9vGlrWrk+j3SxtNP1VVjjls2Y74NTyNLJDLfU7fuurLXcCkFHUV8RnvF+tKi2ZriN C7wEgHndNHREWdwxXs0g9JuL/X4EJre3j/O7cVA3wcDQaxPUkFU4F295iGMFzN49jmb0Q Oz1Ac4E/g5b7cxhVU69QtMj8mtSv6wEaBhtWb6c+Z1wfjvPj8FBRoMfDkUVL461narxKw X05G0/fevEh3zYYzfPo7dfpVrG5pqH1/DI2IcybE4nFCdMCBGBL2184Ogf3o2z4Jqu5L0 bxzAfFeqKjN5PYCdJblPvp/jG0EBd5stOspqLqNkrzex6csZRcSIgtCOSuhC+PZi9cw== X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796253038; h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:From:To: Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=2rg1VfGKXExQyrUrcx10YEc2U/kJAW7G5ZtrGS85QMA=; b=G4O0PPp8OqPgzWOb876C3l6I4gaH+K+9nIxOdvaWQRJ4aChrn7N8DnyFobJxcBViquIc O591f7K6wI55KzDZf0IKGxH2JfW9ENRz3PlMh6XiIE6223xo1NGx7bTy4P/aWi0ixdouU GSOOArIndM46n6rC8eZGuNv1/EBxJrOzQ2kDe744/BFQ912u3RVHxQj9snQ5myHKBjWV/ riLdzRqIpFDmN5uKP17TZzFoMEkareUgWo6yyu5B9duxewmoYKVtKp9+euN6uqzU/NbW7 BYPAcgbljMy0VpAqHGfNIE9JSuPmdaGYM3iYpQT6GTmtctlS3XWC8JwDw+xrjK/oEGg== X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dkim=pass header.d=pengutronix.de header.i=@pengutronix.de header.a=rsa-sha256 header.s=20260414 header.b="csXksp/8"; dmarc=none header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=pass header.oldest-pass=0 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 BBC63606A33C; Wed, 2 Dec 2026 23:10:38 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pengutronix.de header.i=@pengutronix.de header.a=rsa-sha256 header.s=20260414 header.b=csXksp/8 X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=185.203.200.13 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796253037; b=FS9H+N3ovNYzTjo95SUU2xth8BPa07IhHNze7Qk/JPiBvGVXf81UpKCmJfQwse0g8yYS xmNcXq+T4hiTchC32oQkFYx5WWMdUIUHfVdZrPTW640JzLpfH0aoRxRyj2u9LPy1HnNIx RVPM9F23q4+8U4OOsTJy8xyCKYd3Jvq7Nj6VX8u3Y0Y0zqpB8kdrOLZcNrwf8hpI+AROp QbIt/C5Lq6M5GteQxxCe60OurXEzq95lCtDjQ5+g446LU1qh3SOwfIRXqpQewiC8+Q+ww NFNlIKs0WQsAbXTAsCV1gCkmPw5UkugzcF6s2Cydep/ljREqPeiJ/cxDoeQvTOqN3UA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796253037; h=DMARC-Filter:Received:DKIM-Signature:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=2rg1VfGKXExQyrUrcx10YEc2U/kJAW7G5ZtrGS85QMA=; b=NfdhGBMbNwipbDTsifmfxhlVtB98d8c/n3D6Q9ceBtCnBPCS1F0M2yiPbSaJ6K2Nv1zx xsBVeK7GNYPiud0bdgg42TzV2J4aSMya+7QvWvUhp6jJYX/CDyuP/ydI357PCb8Liewra 4MC8gG6JmEkwKwjpKEP3d2DTfBH97r8UNwcUHHTcy56OxzhnY0361LtSsvxlqUriXUchS htFZaX/xFuRWVn0PUCz3g165Lysfs3Q6vn6TOAOzq7Xc4NcsSfYsauCL+eeymbnX+jFHI hOdaNnwllcfZCbyKsE08r5i+tsw0g28eg1JVofXKdRxVgcN4EBB9txXBGrU8bflLxNw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; dkim=pass header.d=pengutronix.de header.i=@pengutronix.de header.a=rsa-sha256 header.s=20260414 header.b="csXksp/8"; arc=pass header.oldest-pass=0 smtp.remote-ip=185.203.200.13 X-Received: from mx1.white.stw.pengutronix.de (mx1.white.stw.pengutronix.de [185.203.200.13]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 02A11606A32F; Wed, 2 Dec 2026 23:10:37 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 02A11606A32F X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de X-Received: from pengutronix.de (unknown [IPv6:2a0e:1580:1000::2dff:fe0e:e982]) (Authenticated sender: mkl@pengutronix.de) by mx1.white.stw.pengutronix.de (Postfix) with ESMTPSA id 51330205BD6; Thu, 03 Dec 2026 00:10:31 +0100 (CET) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pengutronix.de; s=20260414; t=1796253031; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2rg1VfGKXExQyrUrcx10YEc2U/kJAW7G5ZtrGS85QMA=; b=csXksp/8EjZZk1QrNJplFjX+fS3lEPam0eH7gEMh8Xi0GYiNc2M22yCbDz86JTu5EK3xt3 ySfiISMBSHfbRwMY6hspU8CIgl1l0Uhlvv+aVBhWNSpd1ICW+CNM8DdANxmlStlUnRfmtY N1bbpgR7nTaviq3PTSaZRQeK6nUN1Qn+ca5I1E+JI+dUocvvmIE1kIl4uyL5MdUXhO28DS O4A/zMYFPQupxhgcQTMxBsYoKd526FSevTv7skgizH3eAg9gP6CBbA3z9c5hqpdcAnagra luPU2GRGWEHt3xF5S+T1b2Z164XYmddxdwiG9Zx6XC5DyTMdbaaZ3Ejpnry44w== X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=pengutronix.de; s=20260414; t=1796253031; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2rg1VfGKXExQyrUrcx10YEc2U/kJAW7G5ZtrGS85QMA=; b=YQY0LDqA2Cdofs5zJJgameFz7NQVu6wOjXDOQC9LoYAFefSSK8hwV40cdVq8NlHIo6g5Td MLEweMEe6gXb96jyaiA0/2ElTR+eI8224QR92xaiGOL9NFgaCgyqiE/4LKaAPhgxGnnDwy 513Fkft0MkpbLHdlv0+8a/anwgv+XMCLfFFrq7XOuJ92uYdRThvgEc6O0G2tYAuBi0vQA4 LvInbfps1FQsqqN3TuswdT6an5w+0na0PpKZbt6bjsZ00B55jRRARtpK06aQ/4aFWhPTTs WtGlTMbiOKlx6w/TSpHzK2K48EyEyvk2+sv3YIByoakJBkDD1v6/PbEdv2+KhA== X-ARC-Seal: i=1; s=20260414; d=pengutronix.de; t=1796253031; a=rsa-sha256; cv=none; b=BFK43sGy0O7U/JZLLoCU4KboGNFwmsZwJ78R0ymjMRp82oLo40hXFMyHotyQQ1ZMg3zONT d9y/EGNIilP8YMVRbicYu7AMyn0lHAx6RTjWUSEJf5eRFVeUMcmYrX5uDIAPFe2unt/zli W05JrZ6TRHwxkC9+BF77zxGjkMThuMBakqR+F+fxwbNqEGS3PSuYXKAZ+wzbI6BYxAWkZA 4DLexjfcysUmZhP9k8yhLTzeZHQbeLMMeBGItd+gCWSzGctb6Dc7FyUuQKd+O8zQ61lRaj EatQ6HsUEHtPqNxtLNWhSWuaOGvl7+my2DCxH0FBypVvi/BgfhKaz3TWgyOVNQ== X-ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=mkl@pengutronix.de smtp.mailfrom=mkl@pengutronix.de X-Cc: davem@davemloft.net, kuba@kernel.org, linux-can@vger.kernel.org, kernel@pengutronix.de, Stéphane Grosjean <s.grosjean@peak-system.fr>, stable@vger.kernel.org, Marc Kleine-Budde <mkl@pengutronix.de> X-Mailer: git-send-email 2.53.0 X-In-Reply-To: <20261202230853.2665144-1-mkl@pengutronix.de> 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> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list