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=1796177276; b=M1VgzvkLcYYifN/vcRzwUX/U28z43kU2tjRn1kISSYjkSDncx8SVM47k69j6HsKxNzwk Omiqe4FyrLmSg4TTYlJNnWMc1+PMemUDWyUgt+tuuzyew23fXWdWUPmD99dqJqI37+z7Q ZX96u1+w50inRmVkCDEJZc8BO/w1ZGsCgSSQgoKzIGRtgXD8Bx98vyNzFJ9flS699EhVv npxbMe79S+6OyhGa3/u6L20YbALlSy6ffAyCoXn8fAmiZHyVoOW+AGiCyWlcGdXVApzin wRsv4BrvwtTeMBh0kKRE/VjmKfvox78LGRyVOMOW7sk/qHN72qfMOpi+lWLnJwxGt8A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796177276; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=+qce2v9AG0E8Oezl8tS2RRAJ/eea96sURjh38W46GEw=; b=a6gwZl4cHN0+BA0NgkQXURuwbbVIOEp6LuQRwvoMpZyGHl4ZkXO5psrZB/UGulo75f4M irdM1eJhnI6UTPLT7qtrVhpnRrJi1SmAv2Bk5g/PQYBAdW0OMZHKnwCs9vbZU3g6XxDWk FdNChqiu7X0Lsk0mCrG2eb6dULbZE84jg4m7CTUH5XDsd0uLoUr/8YvuFYUWP4cM8e11M monKzioWPw1wT4AqpbGJIUq7Xdy3oHpi/jEbtZEQEFcFVkkEnVSkhe/gMUxLcYXy1HvyE o+sQEKPBB/fnpqVujWyz+sYQPF+Z+A1K38Bejse1dfvH5bRINi929lyHNJ6wFg8YXSQ== 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=b9De0Db8; 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 9D0A5606A323; Wed, 2 Dec 2026 02:07:56 +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=b9De0Db8 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF3081F00893; Wed, 2 Dec 2026 02:07:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796177276; bh=+qce2v9AG0E8Oezl8tS2RRAJ/eea96sURjh38W46GEw=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=b9De0Db8GCHIH/tYzqtPgOUtfp9geO4iVAaeIEz6pVYwZoRlySmgd+6ROGXeaLOZe EKRnLZP+eixaiLPgb/EhslEPAy9ntirSr/+UX7In/CGn+NIZuGuStvJeO6aPI7FyWt 3ZRZaDygQMNzOOQLqnfmljTqPm6mj/gatGo272SejBVredBK192VBZRHwN0wFNQsHD Cd7YMdXl1YzcDWnd3PpYpKul3jUgxrTSlrg5WaA0JQD3r8fJajLJvL122ABQL0Cvep JreT2BMU7tNdLdwmM970QCZnaDhmuCmwWmuZuQvWTk7VWOWlbxzGM2T59A9aH8bDbC SIg/SAfgffp4A== Subject: Re: [PATCH can-next v3 3/6] can: bittiming: can_update_sample_point(): fix sample point error calculation on unsigned operands From: netdev-bot+sashiko@kernel.org To: mkl@pengutronix.de Cc: mailhol@kernel.org, socketcan@hartkopp.net, wg@grandegger.com, davem@davemloft.net, kernel@pengutronix.de, linux-can@vger.kernel.org, 25031212351@stu.xidian.edu.cn, stable@vger.kernel.org, byu@xidian.edu.cn, wencheng@xidian.edu.cn, kuba@kernel.org Date: Wed, 02 Dec 2026 02:07:55 +0000 Message-ID: <179617727537.3142.7162137065977769300@kernel.org> In-Reply-To: <20261130-bittiming-fix-conversion-v3-3-e61f92dc76d0@pengutronix.de> References: <20261130-bittiming-fix-conversion-v3-3-e61f92dc76d0@pengutronix.de> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-can@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] The commit message says this patch fixes a bug, but the change does nothing at this call site. -- can: bittiming: can_update_sample_point(): fix sample point error calculation on unsigned operands This commit replaces abs(sample_point_reference - sample_point) with abs_diff(sample_point_reference, sample_point) in can_update_sample_point(). The commit message presents this as a fix for a wrapped unsigned difference that gets reinterpreted as a small positive value. > can: bittiming: can_update_sample_point(): fix sample point error calculation on unsigned operands > > can_update_sample_point() rates each candidate against the requested > sample point with: > > sample_point_error = abs(sample_point_reference - sample_point); > > Both operands are unsigned int, so the subtraction wraps instead of > becoming negative, and abs() resolves an unsigned int argument to its > int branch. A wrapped difference is therefore reinterpreted as a small > positive value instead of the large error it actually represents. [Severity: Medium] Does this description match what happens in can_update_sample_point()? As far as I can tell, the old and new expressions give the same result in every case where sample_point_error is actually used. The error for each candidate is only kept when the candidate is at or below the reference: if (sample_point <= sample_point_reference && sample_point_error < best_sample_point_error) { In that case the subtraction cannot wrap. sample_point_reference is also always below 1000. It is either bt->sample_point, which can_validate_bittiming() in drivers/net/can/dev/netlink.c bounds: if (bt->sample_point >= 1000) { NL_SET_ERR_MSG(extack, "sample point must be between 0 and 100%"); return -EINVAL; } or it is a fixed default from can_calc_sample_point_nrz() or can_calc_sample_point_pwm(). So the difference never gets close to INT_MAX. That is the only range where the int branch of abs() would return a wrong magnitude. When sample_point > sample_point_reference the subtraction does wrap. Casting it to int still gives the correct small value, not a "large error". The check above also rejects that candidate. The wording looks like it was carried over from the previous commit "can: bittiming: can_calc_bittiming(): fix bitrate error calculation on unsigned operands". There, bt->bitrate can be close to UINT_MAX, so the difference can exceed INT_MAX. That reasoning doesn't seem to apply to the sample point. Could this be described as a consistency cleanup with "No functional change intended" instead of a fix? Other fixes in this series are marked for stable, so a "fix" subject here could get this patch selected for stable backports. Later patches in the series don't change this. -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130-bittiming-fix-conversion-v3-0-e61f92dc76d0%40pengutronix.de