From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
To: Yang Xiwen <forbidden405@outlook.com>,
Andi Shyti <andi.shyti@kernel.org>,
Stephan Gerhold <stephan.gerhold@kernkonzept.com>
Cc: linux-arm-msm@vger.kernel.org, linux-i2c@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] i2c: qup: jump out of the loop in case of timeout
Date: Tue, 1 Jul 2025 14:52:34 +0200 [thread overview]
Message-ID: <64441b8a-2769-479f-8894-05c4580c96a2@oss.qualcomm.com> (raw)
In-Reply-To: <SEYPR02MB55575E3DE3A107D36F5393AD9644A@SEYPR02MB5557.apcprd02.prod.outlook.com>
On 28-Jun-25 17:58, Yang Xiwen wrote:
> On 6/16/2025 12:01 AM, Yang Xiwen via B4 Relay wrote:
>> From: Yang Xiwen <forbidden405@outlook.com>
>>
>> Original logic only sets the return value but doesn't jump out of the
>> loop if the bus is kept active by a client. This is not expected. A
>> malicious or buggy i2c client can hang the kernel in this case and
>> should be avoided. This is observed during a long time test with a
>> PCA953x GPIO extender.
>>
>> Fix it by changing the logic to not only sets the return value, but also
>> jumps out of the loop and return to the caller with -ETIMEDOUT.
>>
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Yang Xiwen <forbidden405@outlook.com>
>> ---
>> drivers/i2c/busses/i2c-qup.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c
>> index 3a36d682ed57..5b053e51f4c9 100644
>> --- a/drivers/i2c/busses/i2c-qup.c
>> +++ b/drivers/i2c/busses/i2c-qup.c
>> @@ -452,8 +452,10 @@ static int qup_i2c_bus_active(struct qup_i2c_dev *qup, int len)
>> if (!(status & I2C_STATUS_BUS_ACTIVE))
>> break;
>> - if (time_after(jiffies, timeout))
>> + if (time_after(jiffies, timeout)) {
>> ret = -ETIMEDOUT;
>> + break;
>> + }
>> usleep_range(len, len * 2);
>> }
>>
>> ---
>> base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
>> change-id: 20250615-qca-i2c-d41bb61aa59e
>>
>> Best regards,
>
> Ping for review. The original logic error is very clear. This patch is also very small and can be reviewed in a short time.
>
> If it insists on waiting for the bit to clear, it should not return -ETIMEDOUT then.
'return -ETIMEDOUT' makes sense here, AFAICT
Konrad
next prev parent reply other threads:[~2025-07-01 12:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-15 16:01 Yang Xiwen via B4 Relay
2025-06-28 15:58 ` Yang Xiwen
2025-07-01 12:52 ` Konrad Dybcio [this message]
2025-07-16 22:17 ` Andi Shyti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=64441b8a-2769-479f-8894-05c4580c96a2@oss.qualcomm.com \
--to=konrad.dybcio@oss.qualcomm.com \
--cc=andi.shyti@kernel.org \
--cc=forbidden405@outlook.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=stephan.gerhold@kernkonzept.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®