]> git.proxmox.com Git - ovs.git/commitdiff
netdev-linux: Avoid division by 0 if kernel reports bad scheduler data.
authorBen Pfaff <blp@ovn.org>
Sat, 18 Aug 2018 17:17:37 +0000 (10:17 -0700)
committerBen Pfaff <blp@ovn.org>
Mon, 20 Aug 2018 16:30:11 +0000 (09:30 -0700)
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>
lib/netdev-linux.c

index 0c42268d9d6cba6b61b3049251efb4f588cefefb..e16ea58a085e1d313eeabbcf1deda96857dce4cc 100644 (file)
@@ -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;
     }