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 B2F5D2E49B4; Tue, 15 Jul 2025 13:33:50 +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=1752586430; cv=none; b=bnZZiRt330izDAtZgjTYjRUsrpe1Oqpsftif5ZyLnRVQrRxUSD9tT3EMlFF2NxrW6G5T94cM9ZNp1G7NyBtOAwlC3KXIXY4UCKsj1NKLIkKVHUH/lO5X7Owk7OEl/fXGqrVwH+/pcnBWOh9mGV8+BKb67jEvC1lKiTc5Du9NTLI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752586430; c=relaxed/simple; bh=zKl22OltK0JT9SSHiC17w9Krc54dlmpkwCvLGkBRCiQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=joDnTkF54Y1u+/nQolw8B9vkSRF1QMLNdsaCE9zcb52MWdDn2xDB4xKhQcMvxTlxIo7pp9WMZggUJWSHTSsG1YF9SjQGLYQozcp90jcvupgIYLaEnK4i7Rdhv+BnKIrR6Rg64V160M9bWlUW1dL13G/fYEBb/9sLlcy7ZwAHcY0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=yiiwjWqP; 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="yiiwjWqP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45E77C4CEF7; Tue, 15 Jul 2025 13:33:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1752586430; bh=zKl22OltK0JT9SSHiC17w9Krc54dlmpkwCvLGkBRCiQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yiiwjWqPF6bHZp4b8/6rPM2d7BQSckCMcoBYXZYmSMijC4XGXNibcWrV2ek+l1mGW gT1xKgkLLwWf6PJTzJtV6jx9Ja4pX0MYH7lVvECy+mFHFIT530bgjASyoE/Up6nBiv b0rMkCT4sBHESAUuFkv3jRrsiPApdvL8wjsm1Fus= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Wolfram Sang , Andi Shyti Subject: [PATCH 5.4 035/148] i2c: tiny-usb: disable zero-length read messages Date: Tue, 15 Jul 2025 15:12:37 +0200 Message-ID: <20250715130801.719606928@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250715130800.293690950@linuxfoundation.org> References: <20250715130800.293690950@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 5.4-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 @@ -140,6 +140,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 = { .master_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),