From 4d25656a231b86455b1c10b737343fcfa72052d6 Mon Sep 17 00:00:00 2001 From: Mike Pattrick Date: Mon, 27 May 2024 15:08:46 -0400 Subject: [PATCH] netdev-linux: Initialize link speed in error conditions. Clang's static analyzer noted that the output from netdev_linux_get_speed_locked can be checked even if this function doesn't set any values. Now we always set those values to a sane default in all cases. Fixes: 19cffe30cfda ("netdev-linux: Avoid deadlock in netdev_get_speed.") Signed-off-by: Mike Pattrick Signed-off-by: Ilya Maximets --- lib/netdev-linux.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 7a2c055f0a5..3f200f28bc1 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -2728,6 +2728,7 @@ netdev_linux_get_speed_locked(struct netdev_linux *netdev, uint32_t *current, uint32_t *max) { if (netdev_linux_netnsid_is_remote(netdev)) { + *current = *max = 0; return EOPNOTSUPP; } @@ -2737,6 +2738,8 @@ netdev_linux_get_speed_locked(struct netdev_linux *netdev, ? 0 : netdev->current_speed; *max = MIN(UINT32_MAX, netdev_features_to_bps(netdev->supported, 0) / 1000000ULL); + } else { + *current = *max = 0; } return netdev->get_features_error; }