Skip to content

Commit

Permalink
netdev-linux: Initialize link speed in error conditions.
Browse files Browse the repository at this point in the history
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: 19cffe3 ("netdev-linux: Avoid deadlock in netdev_get_speed.")
Signed-off-by: Mike Pattrick <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
mkp-rh authored and igsilya committed May 28, 2024
1 parent 0c1b9b0 commit 4d25656
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/netdev-linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}
Expand Down

0 comments on commit 4d25656

Please sign in to comment.