[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190729102611.2338-1-baijiaju1990@gmail.com>
Date: Mon, 29 Jul 2019 18:26:11 +0800
From: Jia-Ju Bai <baijiaju1990@...il.com>
To: davem@...emloft.net, sbrivio@...hat.com, sd@...asysnail.net,
liuhangbin@...il.com, jbenc@...hat.com, dsahern@...il.com,
natechancellor@...il.com, tglx@...utronix.de
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
Jia-Ju Bai <baijiaju1990@...il.com>
Subject: [PATCH] net: geneve: Fix a possible null-pointer dereference in geneve_link_config()
In geneve_link_config(), there is an if statement on line 1524 to check
whether rt is NULL:
if (rt && rt->dst.dev)
When rt is NULL, it is used on line 1526:
ip6_rt_put(rt)
dst_release(&rt->dst);
Thus, a possible null-pointer dereference may occur.
To fix this bug, ip6_rt_put(rt) is called when rt is not NULL.
This bug is found by a static analysis tool STCheck written by us.
Signed-off-by: Jia-Ju Bai <baijiaju1990@...il.com>
---
drivers/net/geneve.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index cb2ea8facd8d..a47a1b31b166 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -1521,9 +1521,10 @@ static void geneve_link_config(struct net_device *dev,
rt = rt6_lookup(geneve->net, &info->key.u.ipv6.dst, NULL, 0,
NULL, 0);
- if (rt && rt->dst.dev)
+ if (rt && rt->dst.dev) {
ldev_mtu = rt->dst.dev->mtu - GENEVE_IPV6_HLEN;
- ip6_rt_put(rt);
+ ip6_rt_put(rt);
+ }
break;
}
#endif
--
2.17.0
Powered by blists - more mailing lists