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 44CAD273D95; Wed, 30 Jul 2025 09:44:25 +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=1753868665; cv=none; b=HFwq0fswRezrKSm0zh5mIgcnH3kgtdRk0SRyj0MEPtqUIVETXZ5NE+r9Cx9Qzby7ajB3y8VBkk88eVKTaerusIM5aRCS/QUUprNN5bD2NMneS9AXCZb8CawBeNm6jUiGRNBgcsmCn4ltLAtnGj8w/6w8LaOvyL2rBUBBLhY3mAY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753868665; c=relaxed/simple; bh=AOBkB7IJmy0ZTGnjEP+0OUm/krOIpylGtKQipeHju1I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bSVvtLTvXFqkxFKIBT3CU09MLIS5aZsQ2lY9JDyE8zfOCXHv9j5x89QXMv2v4XdQMgwSL4ygCu5PdDNfUa6OiQ9ggatCvdmXvymqFJjIdD89f/gjRYKaebcUJe7grdYWi+R7w6PcUV6RdQdq9ZGXCK5ZR5PnjmEEVK4Lt4jm4ag= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xRaGNSKj; 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="xRaGNSKj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8B27C4CEE7; Wed, 30 Jul 2025 09:44:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1753868665; bh=AOBkB7IJmy0ZTGnjEP+0OUm/krOIpylGtKQipeHju1I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xRaGNSKj5F//xzxad2tzbuHXZMtNjygP4ZHQlhz3PTEhOcLfYykpjwr32QglOZga4 skE1Eyc7qYzS8jslG5gZEtSMb9Az8zxw1PFFJEC7G+nMywfFnay5hva5T5PPQHv74Q cEoYmmiq92mWz/SR+VZr1UtqRgFR4IniTCja6lX0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yang Xiwen , Andi Shyti Subject: [PATCH 6.12 046/117] i2c: qup: jump out of the loop in case of timeout Date: Wed, 30 Jul 2025 11:35:15 +0200 Message-ID: <20250730093235.347799509@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250730093233.592541778@linuxfoundation.org> References: <20250730093233.592541778@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: Yang Xiwen commit a7982a14b3012527a9583d12525cd0dc9f8d8934 upstream. 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. Fixes: fbfab1ab0658 ("i2c: qup: reorganization of driver code to remove polling for qup v1") Signed-off-by: Yang Xiwen Cc: # v4.17+ Signed-off-by: Andi Shyti Link: https://lore.kernel.org/r/20250616-qca-i2c-v1-1-2a8d37ee0a30@outlook.com Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-qup.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- 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 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); }