Skip to content

Commit

Permalink
netdev-linux: Avoid division by 0 if kernel reports bad scheduler data.
Browse files Browse the repository at this point in the history
If the kernel reported a value of 0 for the second value in
/proc/net/psched, it would cause a division-by-zero fault in
read_psched().  I don't know of a kernel that would actually do that, but
it's still better to be safe.

Found by clang static analyzer.

Reported-by: Bhargava Shastry <bshastry@sect.tu-berlin.de>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
  • Loading branch information
blp committed Aug 20, 2018
1 parent 3d55b5c commit 323792f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/netdev-linux.c
Expand Up @@ -4126,7 +4126,7 @@ read_psched(void)
VLOG_DBG("%s: psched parameters are: %u %u %u %u", fn, a, b, c, d);
fclose(stream);

if (!a || !c) {
if (!a || !b || !c) {
VLOG_WARN("%s: invalid scheduler parameters", fn);
goto exit;
}
Expand Down

0 comments on commit 323792f

Please sign in to comment.