OSDN Git Service

batman-adv: don't pass a NULL hard_iface to batadv_hardif_put
authorColin Ian King <colin.king@canonical.com>
Fri, 23 Mar 2018 22:53:50 +0000 (22:53 +0000)
committerSimon Wunderlich <sw@simonwunderlich.de>
Sun, 22 Apr 2018 07:29:01 +0000 (09:29 +0200)
In the case where hard_iface is NULL, the error path may pass a null
pointer to batadv_hardif_put causing a null pointer dereference error.
Avoid this by only calling the function if  hard_iface not null.

Detected by CoverityScan, CID#1466456 ("Explicit null dereferenced")

Fixes: 53dd9a68ba68 ("batman-adv: add multicast flags netlink support")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
net/batman-adv/multicast.c

index a11d3d8..a35f597 100644 (file)
@@ -1536,7 +1536,7 @@ out:
 
        if (!ret && primary_if)
                *primary_if = hard_iface;
-       else
+       else if (hard_iface)
                batadv_hardif_put(hard_iface);
 
        return ret;