From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796434225; b=afypHSLTMl1A3Uvunbl1gb3RYxggeO5q81pcQ1iLFZO6mJtauGMJ7kUIvod4ZsHcIzvX zyjgA88fFyn1kYvFudX20ZZU3EfB23J/fEACUSkkIQcjHLt7EYU/JRwFQYgn3ZAYckINj aV90MIKlukVcXDrC/saKPgU1IgkI/PWJkNE0qexoA3Ay+cjf2Vf5PREFhW8a9vJrfGvfQ 3cAotlUp61rdQlQVxnZSM6JeiJlGmhtnxTO2UwnSTNGYHxRBA6+MF+Zk1bo/+xmg1eBml OPDL/+udJedPlbSkjziXa9dPEM04kCySuskABdn0aRodliPY7bKpLAsO8CE9Jmst8hA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796434225; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=rYFIAumf4purjrH2Py6Rc13X1Y4qkAJzKpafRYGtoGc=; b=Vb0W2KUm0FviRlmbf8hNSSpNFG9/GQG9KzLvkluofrKm0RnZPDbu/dBUjJE08LF69Yfc aQdHMGWQ1K5w6qU26t7bA1YJ8ZabxglKz48KaVH8ZwrNVyCi8YzH+1UHxsQHBglqU/TJ3 ymaYVGvIMxUAbSLC4HCwb+a/m+DEKjZYwrZHwuKQkj6RREN1rr6UrSvVcDomXHRlyLme/ qh7R1ewBgk+Xi8SKj1vMWR2g2N0RagcbM42S70SEWICZATTrZ/h/FcmKHI+XwC9D3Vzaq ZGmOvxSzrBZYQq3u35Bumc4BSwb8iBQyK7NKsp5oYG0CCJqdDRO5IWSGXAIqKjA7Vbw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="g/Qp3ODd"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FC4A606A32C for ; Sat, 5 Dec 2026 01:30:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=g/Qp3ODd Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1DA31F00936; Sat, 5 Dec 2026 01:30:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796434224; bh=rYFIAumf4purjrH2Py6Rc13X1Y4qkAJzKpafRYGtoGc=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=g/Qp3ODduA1bttUoRYDD7zZJFC6LSpj7lB5r0QczcxcysZDfaERYRogWlTPfKXJ5B l6b6eU0yryc9Lt/YTPJnywarnE9DpgHiotx4/htql/rTTXbIMYq5BIhUM1qX5j0yvG rE5GYEyrTk7kOuw15Dk+bj9fCRGUzdh7+HV6qzS2QyWxwrnD8P7hr3iOg7ISEGu0z0 34+5dejDekv1VnFXfHpEDCIXnf7elrId8QJAewowsxGxNNxyRzLv6KfZER0Ow2FSlD 5IW4oqqIWiX/kYkj8UmqdZY/KVA4GZ7wvV+E4VFrXZAhtsf8zDN2baqdIS0BtDDgeI 9m9SeKj3xSuDA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] hwmon: (emc2305) fix division by zero for a small tach reading Reply-To: sashiko-reviews@lists.linux.dev To: "Shirong Zhao" Cc: linux-hwmon@vger.kernel.org In-Reply-To: <20261205012416.100-1-shxzhaosr@163.com> References: <20261205012416.100-1-shxzhaosr@163.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 01:30:24 +0000 X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list > emc2305_show_fan() guards the raw 16-bit tach register value with > `if (ret <=3D 0)`, then shifts it right by EMC2305_TACH_REGS_UNUSE_BITS (= 3) > before dividing: >=20 > ret =3D ret >> EMC2305_TACH_REGS_UNUSE_BITS; > ret =3D EMC2305_RPM_FACTOR / ret; >=20 > A tach register value of 1..7 survives the first check but becomes 0 > after the shift, so the division is a divide by zero. The register value > comes from the fan controller (the driver never writes it); reading the > read-only fan1_input attribute of a faulty or emulated controller that > reports 1..7 therefore crashes the kernel. Userspace only triggers the > read; the zero divisor is device-provided. >=20 > Re-check for zero after the shift. >=20 > Fixes: 0d8400c5a2ce ("hwmon: (emc2305) add support for EMC2301/2/3/5 RPM-= based PWM Fan Speed Controller.") > Signed-off-by: Shirong Zhao Sashiko has reviewed this patch and found no issues. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205012416.100-= 1-shxzhaosr@163.com?part=3D1