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 2C0A4331203; Sat, 12 Sep 2026 16:21:59 +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=1789230120; cv=none; b=AOPQ6xkp8IJbDiylV7Tctw1qT+xzIvxctf/8ag+mFIw/vib35QRGvPUlvfAsWScNAb7XEM/zQbGb2/hxFG6GqcE0GWjeKUNKjs3FP5vq4dKzAeRoBKgcHoQOzOP9g/bo2zaFiAiGwnBSG/CH7+shf9/vJGS/8LcuxRbFASaASgk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789230120; c=relaxed/simple; bh=6Gg17IwwzK+y8dcfiBHCFVdEa9nzl7PZ22qvsS6zFmo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XVyuMKT6RBcTLKTGWHLGj6j42EmMnGwwwX2H+0x89hs03jPdeADTty13PU23PTdPd1Hlo4XGLpaoOzPo2CHK0WGD2+myNxdlIUElasbtIS3KRwULy6kPkBsyRfGPnmBMJPbFwrb4WlS4c/9910E716f/jA/nLfxW5y5+xdYbNO0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=QtzPbmZ+; 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="QtzPbmZ+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E67911F000FF; Sat, 12 Sep 2026 16:21:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789230119; bh=IoN7BG7v9js6bEN/vbswwCSSpCNHZc2nHFWyE3u8oNE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QtzPbmZ+yT1U/EngnyIs6Ruglj2Nq5s1ygO0IRoV17gjuNcs/uCeB/dwDhbbtgOh9 dWowTlb7m38bec+ZWCFQtYCoLQxKropQ1MEi/dtq4KwUdYMRaG621wK64Zx1FnVel2 rxTdotf2Sde0ZxuXrzTeAeVJKbvdjinzWixnE2ag= 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.1 0728/1191] w1: ds2482: Fix signedness bug in ds2482_w1_triplet() Date: Sat, 12 Sep 2026 08:57:36 +0200 Message-ID: <20260912065604.632197829@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065548.086904252@linuxfoundation.org> References: <20260912065548.086904252@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.1-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 62c44616d8a92..ffb1ebb1d2b0c 100644 --- a/drivers/w1/masters/ds2482.c +++ b/drivers/w1/masters/ds2482.c @@ -312,6 +312,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