Netdev List
 help / color / mirror / Atom feed
* [PATCH net] tipc: fix division by zero in perc()
@ 2026-11-03 22:54 Tristan Madani
  2026-11-03 22:58 ` netdev-bot+sinfo
  0 siblings, 1 reply; 2+ messages in thread
From: Tristan Madani @ 2026-11-03 22:54 UTC (permalink / raw)
  To: Jon Maloy, Tung Quang Nguyen, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman
  Cc: Richard Alpe, Ying Xue, Erik Hugne, netdev, tipc-discussion,
	linux-kernel, Tristan Madani

From: Tristan Madani <tristan@talencesecurity.com>

The perc() function divides count by total without checking whether
total is zero. When link statistics are queried on a freshly
established link that has not yet exchanged messages,
TIPC_NLA_STATS_MSG_PROF_TOT is zero, causing a division by zero
in tipc_nl_compat_link_stat_dump().

Add a zero check to return 0 when total is zero.

Fixes: f2b3b2d4ccbf ("tipc: convert legacy nl link stat to nl compat")
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
 net/tipc/netlink_compat.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c
index d9a4f94ea2d43..75f3193a2a6cf 100644
--- a/net/tipc/netlink_compat.c
+++ b/net/tipc/netlink_compat.c
@@ -497,6 +497,9 @@ static int tipc_nl_compat_bearer_disable(struct tipc_nl_compat_cmd_doit *cmd,
 
 static inline u32 perc(u32 count, u32 total)
 {
+	if (!total)
+		return 0;
+
 	return (count * 100 + (total / 2)) / total;
 }
 
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] tipc: fix division by zero in perc()
  2026-11-03 22:54 [PATCH net] tipc: fix division by zero in perc() Tristan Madani
@ 2026-11-03 22:58 ` netdev-bot+sinfo
  0 siblings, 0 replies; 2+ messages in thread
From: netdev-bot+sinfo @ 2026-11-03 22:58 UTC (permalink / raw)
  To: Tristan Madani
  Cc: Jon Maloy, Tung Quang Nguyen, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Richard Alpe, Ying Xue,
	Erik Hugne, netdev, tipc-discussion, linux-kernel, Tristan Madani

Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - How the issue was discovered, e.g. hit in production, hit during
   development, syzbot report, manual code inspection, LLM or static
   analysis tool scan.

 - Whether the issue was actually triggered, or is only theoretical
   (e.g. found by code inspection). If it was triggered please include
   the symptoms, like the stack trace or error messages.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account. If the series needs another revision for
other reasons, please include the information in the commit messages
then.

The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-03 22:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-03 22:54 [PATCH net] tipc: fix division by zero in perc() Tristan Madani
2026-11-03 22:58 ` netdev-bot+sinfo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox