From: Tristan Madani 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 --- 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