* [PATCH net] eth: fbnic: Fix counter roll-over issue
@ 2025-11-25 21:17 Mohsin Bashir
2025-11-27 3:16 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Mohsin Bashir @ 2025-11-25 21:17 UTC (permalink / raw)
To: netdev
Cc: alexanderduyck, andrew+netdev, davem, edumazet, horms,
jacob.e.keller, kernel-team, kuba, lee, mohsin.bashr, pabeni,
sanman.p211993
Fix a potential counter roll-over issue in fbnic_mbx_alloc_rx_msgs()
when calculating descriptor slots. The issue occurs when head - tail
results in a large positive value (unsigned) and the compiler interprets
head - tail - 1 as a signed value.
Since FBNIC_IPC_MBX_DESC_LEN is a power of two, use a masking operation,
which is a common way of avoiding this problem when dealing with these
sort of ring space calculations.
Fixes: da3cde08209e ("eth: fbnic: Add FW communication mechanism")
Signed-off-by: Mohsin Bashir <mohsin.bashr@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
drivers/net/ethernet/meta/fbnic/fbnic_fw.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_fw.c b/drivers/net/ethernet/meta/fbnic/fbnic_fw.c
index c87cb9ed09e7..fcd9912e7ad3 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_fw.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_fw.c
@@ -201,7 +201,7 @@ static int fbnic_mbx_alloc_rx_msgs(struct fbnic_dev *fbd)
return -ENODEV;
/* Fill all but 1 unused descriptors in the Rx queue. */
- count = (head - tail - 1) % FBNIC_IPC_MBX_DESC_LEN;
+ count = (head - tail - 1) & (FBNIC_IPC_MBX_DESC_LEN - 1);
while (!err && count--) {
struct fbnic_tlv_msg *msg;
--
2.47.3
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net] eth: fbnic: Fix counter roll-over issue
2025-11-25 21:17 [PATCH net] eth: fbnic: Fix counter roll-over issue Mohsin Bashir
@ 2025-11-27 3:16 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-11-27 3:16 UTC (permalink / raw)
To: Mohsin Bashir
Cc: netdev, alexanderduyck, andrew+netdev, davem, edumazet, horms,
jacob.e.keller, kernel-team, kuba, lee, pabeni, sanman.p211993
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 25 Nov 2025 13:17:04 -0800 you wrote:
> Fix a potential counter roll-over issue in fbnic_mbx_alloc_rx_msgs()
> when calculating descriptor slots. The issue occurs when head - tail
> results in a large positive value (unsigned) and the compiler interprets
> head - tail - 1 as a signed value.
>
> Since FBNIC_IPC_MBX_DESC_LEN is a power of two, use a masking operation,
> which is a common way of avoiding this problem when dealing with these
> sort of ring space calculations.
>
> [...]
Here is the summary with links:
- [net] eth: fbnic: Fix counter roll-over issue
https://git.kernel.org/netdev/net/c/6d66e093e074
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-11-27 3:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-25 21:17 [PATCH net] eth: fbnic: Fix counter roll-over issue Mohsin Bashir
2025-11-27 3:16 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).