From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 F0A3D3451C1; Sat, 12 Sep 2026 14:17:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789222640; cv=none; b=i7/CEwUT9yuX2p32Etj1XbkD9yDd0qktIugH+TBQbzZvD9ZF09F1ZU350VSW5EcMI0DHG/+FPY+zek2RoTZACeAZfrIEw+J38DBuwjAUC+xxwuq8nHUhabw0e9h/QO0lAe39I36bPGC01Yn0JIhXnEEjQxEfVD8rCv6TH2cC4D8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789222640; c=relaxed/simple; bh=AFVOlB7CqeF36+Mf+fWZv8DbLXM9OZBdChQVUib37Xc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tLIZHJX0FOYuSzm9TFbrVA2VSswX++lpLuFVAfmNZiz2RN2rFm2rsC0jzhELmIqgVkfS/8IwDvgT+UyQqD2luRZgAsIeeWiuDYFHctBEXuMWnl4CBaHbexfpWmDImZ//ACeTAN4m/YD53ditgl92rUIa+r7TRCarserqPIIgITs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=wibITAO5; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="wibITAO5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56C931F000FF; Sat, 12 Sep 2026 14:17:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789222637; bh=M5azCrx7wLaENng8gHPz/6iudNxA8+JNWYv6THy5b+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=wibITAO54f29iyNxXNPDmz2a8X98Pau59GSbm7GO4kDci/OtTp92rBtcFC+KshAXc odtL6BROnQ1euSVEt4/U4INPWcWJ6bpgIliztcIpEA++Rs7dVyaDq8jLZ8v4l0aak6 pTYaIst7Ef0TixKrO5mzyJhI2aETarrAPXkmmeWs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, sashiko-bot , Srinivas Kandagatla , Vinod Koul , Sasha Levin Subject: [PATCH 6.6 0625/1424] soundwire: qcom: Fix port exhaustion check in stream_alloc_ports Date: Sat, 12 Sep 2026 08:50:57 +0200 Message-ID: <20260912065621.287081240@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065607.279695368@linuxfoundation.org> References: <20260912065607.279695368@linuxfoundation.org> User-Agent: quilt/0.69 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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Srinivas Kandagatla [ Upstream commit 6ccec91c3535b07310e12d32fe9c67ff8d31d965 ] find_first_zero_bit(mask, n) returns n (not n+1) when all bits are set, so the guard `pn > maxport` is never true on exhaustion. The driver would silently call set_bit(maxport, port_mask) and assign the out-of-range port instead of returning -EBUSY. Fix the comparison to `pn >= maxport`. Fixes: 02efb49aa805 ("soundwire: qcom: add support for SoundWire controller") Reported-by: sashiko-bot Assisted-by: Claude Sonnet 4.6 Signed-off-by: Srinivas Kandagatla Link: https://patch.msgid.link/20260701193006.4113-2-srinivas.kandagatla@oss.qualcomm.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/soundwire/qcom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c index e3ae4e4e07ac5..093ed8febe16c 100644 --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c @@ -1168,7 +1168,7 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl, else pn = find_first_zero_bit(port_mask, maxport); - if (pn > maxport) { + if (pn >= maxport) { dev_err(ctrl->dev, "All ports busy\n"); ret = -EBUSY; goto err; -- 2.53.0