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 78CE1340D9D; Sat, 12 Sep 2026 10:18:38 +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=1789208319; cv=none; b=KZrxE3BoCE6wtHz49cRTgr6mQjMQ9pmS2iL2AxpBdemOy1IT4DjQaLmmN3GBQEFP7b0IdHtS227HDGDwqdIhs3bdrFpG5BnjinVtVSixJDbZqseL6Xc3xAlKIl9EXeC7C5pQoU2myOD6gLnMM0ODQEmlkx1uSI9V/qFcODk545U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789208319; c=relaxed/simple; bh=xMo0r7Q+jNPIgwtVPKmbM6znRLw6BM14vbGZyOzBX+0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=imxww9Ys+iOJHmIpXP2rN3Xrb+2lpxXW5GZFj1AmV+y9e/mpvn/uDN7rasLR5MgH0DdAiuLJ3DIXDpDzDJZ0jYz60xdXUdJF1vNH6VMwRW4fRe9/uISA96hBqg7yBUB8j85AghY4cH8FBQsFNOJdzNTrAe0WetfeGis+okiyB+w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=UU3FJi3u; 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="UU3FJi3u" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8C091F000FF; Sat, 12 Sep 2026 10:18:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789208317; bh=QhOlMJQVVUDOA6iWVE32u8VYAX0xIrQhPyboSexYcgk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=UU3FJi3uNzpqYOOqjJkWMl763nApkcxhTCya8XkOe5w+I4HHF8OWIQXGGztyOCTDb QAT4U097iG8NPprYa/DaQh3jo3WGqjZmMFldfrrJ3MXB02WTh6LNvMWBiJNUpgE1wp sX2BbYZWkR9dzfaN/czRweRAN14XaUgPVwVTA9no= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Babanpreet Singh , Krzysztof Kozlowski , Sasha Levin Subject: [PATCH 6.18 0591/1518] w1: ds2482: Fix signedness bug in ds2482_w1_triplet() Date: Sat, 12 Sep 2026 08:46:00 +0200 Message-ID: <20260912065636.795678608@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065623.398859879@linuxfoundation.org> References: <20260912065623.398859879@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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Babanpreet Singh [ Upstream commit 4d3721b204f961e905714954ff95633337b768e3 ] ds2482_wait_1wire_idle() returns the status register value (0..255) on success, or a negative value on I2C failure: -1 when selecting the status register fails, or a negative errno from i2c_smbus_read_byte(). ds2482_w1_triplet() feeds that result into "return (status >> 5);" without checking for errors, and the function returns u8. For a negative status the arithmetic shift keeps the sign and the u8 truncation fabricates a triplet result whose meaning depends on the errno value: -1 and -EIO happen to become 0xff, whose set low bits make w1_search() abort, but -ETIMEDOUT (-110 >> 5 = -4) becomes 0xfc - "devices responded on both branches, wrote 1" - and -EOPNOTSUPP (-95 >> 5 = -3) becomes 0xfd - "only the zero branch responded". w1_search() then continues the ROM search with a fabricated direction bit instead of aborting, and the corrupted id is either rejected by the ROM CRC (existing device missed) or registers a phantom slave. The function already defines an in-band error value: status is initialized to (3 << 5), which decodes to 3 (both branch bits set, "no device responded") and makes w1_search() terminate the search when sending the triplet command fails. Decode a negative status to the same value. Found by smatch: drivers/w1/masters/ds2482.c:314 ds2482_w1_triplet() warn: signedness bug returning '(-67108864)' Fixes: baf12ae29ab4 ("[PATCH] W1: Add the DS2482 I2C-to-w1 bridge driver.") Assisted-by: Claude:claude-sonnet-5 Signed-off-by: Babanpreet Singh Link: https://patch.msgid.link/20260714041011.7-1-bbnpreetsingh@gmail.com Signed-off-by: Krzysztof Kozlowski Signed-off-by: Sasha Levin --- drivers/w1/masters/ds2482.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/w1/masters/ds2482.c b/drivers/w1/masters/ds2482.c index e2a568c9a43aa..0c93bf338a6ef 100644 --- a/drivers/w1/masters/ds2482.c +++ b/drivers/w1/masters/ds2482.c @@ -310,6 +310,10 @@ static u8 ds2482_w1_triplet(void *data, u8 dbit) mutex_unlock(&pdev->access_lock); + /* On bus error, decode to 3 (no device responded) to abort the search */ + if (status < 0) + status = 3 << 5; + /* Decode the status */ return (status >> 5); } -- 2.53.0