summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-04-26 08:05:23 +0200
committerThomas Haller <thaller@redhat.com>2022-04-26 08:05:23 +0200
commite1a077a913da40f05a1c958e679dc1f927d1da60 (patch)
treecdd3344cbb479a11735bd1b35ef975cf5f96d11a
parent3f4f1dda25a7041d22948e09ec42cf5d4c9b2163 (diff)
downloadlibnl-e1a077a913da40f05a1c958e679dc1f927d1da60.tar.gz
route/link: avoid accessing af_ops after af_free() in rtnl_link_set_family()
-rw-r--r--lib/route/link.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/route/link.c b/lib/route/link.c
index 65f3dbb7..c1916e72 100644
--- a/lib/route/link.c
+++ b/lib/route/link.c
@@ -2101,9 +2101,10 @@ void rtnl_link_set_family(struct rtnl_link *link, int family)
link->ce_mask |= LINK_ATTR_FAMILY;
if (link->l_af_ops) {
- af_free(link, link->l_af_ops,
- link->l_af_data[link->l_af_ops->ao_family], NULL);
- link->l_af_data[link->l_af_ops->ao_family] = NULL;
+ int ao_family = link->l_af_ops->ao_family;
+
+ af_free(link, link->l_af_ops, link->l_af_data[ao_family], NULL);
+ link->l_af_data[ao_family] = NULL;
}
link->l_af_ops = af_lookup_and_alloc(link, family);