diff options
author | Thomas Haller <thaller@redhat.com> | 2022-04-22 20:23:03 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2022-04-22 20:23:13 (GMT) |
commit | d52dbcb611a4c409db5e265858b13eef1609b044 (patch) | |
tree | 54c52c5d8867713a8f97b1aaea4e1d20ce738784 /lib/route | |
parent | 1f61096c82c0b8f1eecef1d74f67985158a306e1 (diff) | |
download | libnl-d52dbcb611a4c409db5e265858b13eef1609b044.zip libnl-d52dbcb611a4c409db5e265858b13eef1609b044.tar.gz libnl-d52dbcb611a4c409db5e265858b13eef1609b044.tar.bz2 |
route: fix check for NULL in nh_encap_dump()
Error: REVERSE_INULL (CWE-476):
libnl-3.6.0/lib/route/nexthop_encap.c:35: deref_ptr: Directly dereferencing pointer "rtnh_encap->ops".
libnl-3.6.0/lib/route/nexthop_encap.c:37: check_after_deref: Null-checking "rtnh_encap->ops" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
# 35| nh_encap_type2str(rtnh_encap->ops->encap_type));
# 36|ยทยทยท
# 37|-> if (rtnh_encap->ops && rtnh_encap->ops->dump)
# 38| rtnh_encap->ops->dump(rtnh_encap->priv, dp);
# 39| }
Diffstat (limited to 'lib/route')
-rw-r--r-- | lib/route/nexthop_encap.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/route/nexthop_encap.c b/lib/route/nexthop_encap.c index 94bcb60..2382886 100644 --- a/lib/route/nexthop_encap.c +++ b/lib/route/nexthop_encap.c @@ -31,10 +31,13 @@ static const char *nh_encap_type2str(unsigned int type) void nh_encap_dump(struct rtnl_nh_encap *rtnh_encap, struct nl_dump_params *dp) { + if (!rtnh_encap->ops) + return; + nl_dump(dp, " encap %s ", nh_encap_type2str(rtnh_encap->ops->encap_type)); - if (rtnh_encap->ops && rtnh_encap->ops->dump) + if (rtnh_encap->ops->dump) rtnh_encap->ops->dump(rtnh_encap->priv, dp); } |