diff options
author | Yunjian Wang <wangyunjian@huawei.com> | 2021-08-31 15:51:18 +0800 |
---|---|---|
committer | Ilya Maximets <i.maximets@ovn.org> | 2021-09-16 01:12:53 +0200 |
commit | a566c02a2c5775b1f85bdcf3255ffbb5d4c4ecd5 (patch) | |
tree | aef62499489fc3626caaf471c3dcc85b28f18439 /lib | |
parent | 5e86db383ff8e74bc0483c5db50dd66a806f0857 (diff) | |
download | openvswitch-a566c02a2c5775b1f85bdcf3255ffbb5d4c4ecd5.tar.gz |
odp-util: Fix a null pointer dereference in odp_nsh_key_from_attr__().
This patch fixes (dereference after null check) coverity issue.
We should add null check of 'nsh_mask' to avoid passing NULL pointer
to memcpy() because the 'nsh_mask' maybe null.
Addresses-Coverity: ("Dereference after null check")
Fixes: 81fdabb94dd7 ("nsh: fix nested mask for OVS_KEY_ATTR_NSH")
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Acked-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/odp-util.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/odp-util.c b/lib/odp-util.c index 7729a9060..5fcf90053 100644 --- a/lib/odp-util.c +++ b/lib/odp-util.c @@ -2941,7 +2941,7 @@ odp_nsh_key_from_attr__(const struct nlattr *attr, bool is_mask, const struct ovs_nsh_key_md1 *md1 = nl_attr_get(a); has_md1 = true; memcpy(nsh->context, md1->context, sizeof md1->context); - if (len == 2 * sizeof(*md1)) { + if (nsh_mask && (len == 2 * sizeof *md1)) { const struct ovs_nsh_key_md1 *md1_mask = md1 + 1; memcpy(nsh_mask->context, md1_mask->context, sizeof(*md1_mask)); |