From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7BBD672610; Thu, 3 Jul 2025 14:48:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751554090; cv=none; b=W6Tf2ibhVCs0MHp64gAGwrskuyl3V/MT7UwEmGZb6ES1HPIR0zx4agHjvuYErAAKxJ15YqonSYjrWd6Efg8dqZT/oHyK6AStifV4G1ACEg8k3L7QQrMvKVqsRvxgeUgb3tkCXgcIL122/ZtgNpNiN44nXP+Mvq1GBBB88YdcwJ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751554090; c=relaxed/simple; bh=Aju9xFu+B9x86U8FAKUMtpToXeP6D6Lv2jw17+4+7eU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mEbQE37gWd6aRVbOXmcBFLwpm70Eoc0RSc4eiCUfYfImf/WUyVBT5WsmJt9ztdLB3XYZ0UraLQKQrqv/kmX/y0ltWcnwPii3Qug1HjhRUHcc/WrJm1DsYCU4SFi7lno1MjInAsR5jfHsH+gGiMonOqbc3d9yWPPEqKvY8yjUwWQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=rUYfJrZT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="rUYfJrZT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D507EC4CEE3; Thu, 3 Jul 2025 14:48:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1751554090; bh=Aju9xFu+B9x86U8FAKUMtpToXeP6D6Lv2jw17+4+7eU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rUYfJrZT4MMWK/S3TVE5uDnpuSEDi19OcsuBBdzFlXuOXhqnQWUmdZ2S6jebvtBzQ 3cn8JEEZBTsO0V8pM5TgthAKBZTMav0jmHlJf9AuB/7BDEJJIXKw1x1YCTto/P5VKn vkokKpMb+y4TGLeagiHegj5RrCDd6GttflEbkJ7U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Wolfram Sang , Andi Shyti Subject: [PATCH 6.12 077/218] i2c: tiny-usb: disable zero-length read messages Date: Thu, 3 Jul 2025 16:40:25 +0200 Message-ID: <20250703143959.021323511@linuxfoundation.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250703143955.956569535@linuxfoundation.org> References: <20250703143955.956569535@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Wolfram Sang commit cbdb25ccf7566eee0c2b945e35cb98baf9ed0aa6 upstream. This driver passes the length of an i2c_msg directly to usb_control_msg(). If the message is now a read and of length 0, it violates the USB protocol and a warning will be printed. Enable the I2C_AQ_NO_ZERO_LEN_READ quirk for this adapter thus forbidding 0-length read messages altogether. Fixes: e8c76eed2ecd ("i2c: New i2c-tiny-usb bus driver") Signed-off-by: Wolfram Sang Cc: # v2.6.22+ Signed-off-by: Andi Shyti Link: https://lore.kernel.org/r/20250522064349.3823-2-wsa+renesas@sang-engineering.com Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-tiny-usb.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/i2c/busses/i2c-tiny-usb.c +++ b/drivers/i2c/busses/i2c-tiny-usb.c @@ -138,6 +138,11 @@ out: return ret; } +/* prevent invalid 0-length usb_control_msg */ +static const struct i2c_adapter_quirks usb_quirks = { + .flags = I2C_AQ_NO_ZERO_LEN_READ, +}; + /* This is the actual algorithm we define */ static const struct i2c_algorithm usb_algorithm = { .xfer = usb_xfer, @@ -246,6 +251,7 @@ static int i2c_tiny_usb_probe(struct usb /* setup i2c adapter description */ dev->adapter.owner = THIS_MODULE; dev->adapter.class = I2C_CLASS_HWMON; + dev->adapter.quirks = &usb_quirks; dev->adapter.algo = &usb_algorithm; dev->adapter.algo_data = dev; snprintf(dev->adapter.name, sizeof(dev->adapter.name),