net: sched: act_tunnel_key: fix NULL pointer dereference during init
authorVlad Buslov <vladbu@mellanox.com>
Mon, 25 Feb 2019 15:28:27 +0000 (17:28 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 25 Feb 2019 18:13:38 +0000 (10:13 -0800)
Metadata pointer is only initialized for action TCA_TUNNEL_KEY_ACT_SET, but
it is unconditionally dereferenced in tunnel_key_init() error handler.
Verify that metadata pointer is not NULL before dereferencing it in
tunnel_key_init error handling code.

Fixes: ee28bb56ac5b ("net/sched: fix memory leak in act_tunnel_key_init()")
Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Reviewed-by: Davide Caratti <dcaratti@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/act_tunnel_key.c

index 8b43fe0130f73039e3f1802701df910e079fc4ba..3f943de9a2c975df258e5eb6ae5688b016f0b5d6 100644 (file)
@@ -377,7 +377,8 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
        return ret;
 
 release_tun_meta:
-       dst_release(&metadata->dst);
+       if (metadata)
+               dst_release(&metadata->dst);
 
 err_out:
        if (exists)