summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2018-08-18 10:17:37 -0700
committerBen Pfaff <blp@ovn.org>2018-08-20 09:30:11 -0700
commit1bab4901c45c9c7b0121836ccb2aa2b004a0cfd6 (patch)
treec82e371e9f5a25f4369a4fa8f05a06f2a68e35a8 /lib
parent1dd218ae6449a9b55ff205f49fc0adaf1644d16e (diff)
downloadopenvswitch-1bab4901c45c9c7b0121836ccb2aa2b004a0cfd6.tar.gz
netdev-linux: Avoid division by 0 if kernel reports bad scheduler data.
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>
Diffstat (limited to 'lib')
-rw-r--r--lib/netdev-linux.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index 0c42268d9..e16ea58a0 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -5166,7 +5166,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;
}