From aa6647214655230b8ec514fd40e4b9187814aa8d Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 3 Mar 2023 12:03:15 +0100 Subject: [PATCH] platform: fix test_link_set_properties() The link object is no longer valid after the cache gets updated in nm_platform_link_change(). Fixes: e02fd76d9fce ('platform: support changing link properties') --- src/core/platform/tests/test-link.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/platform/tests/test-link.c b/src/core/platform/tests/test-link.c index eb351eaa7d..c38fde42b5 100644 --- a/src/core/platform/tests/test-link.c +++ b/src/core/platform/tests/test-link.c @@ -2588,6 +2588,7 @@ test_link_set_properties(void) const NMPlatformLink *link; NMPlatformLinkProps props; NMPlatformLinkChangeFlags flags; + int ifindex; props = (NMPlatformLinkProps){ .tx_queue_length = 599, @@ -2597,10 +2598,10 @@ test_link_set_properties(void) flags = NM_PLATFORM_LINK_CHANGE_TX_QUEUE_LENGTH | NM_PLATFORM_LINK_CHANGE_GSO_MAX_SIZE | NM_PLATFORM_LINK_CHANGE_GSO_MAX_SEGMENTS; - link = nmtstp_link_dummy_add(NM_PLATFORM_GET, FALSE, "dummy1"); - g_assert(nm_platform_link_change(NM_PLATFORM_GET, link->ifindex, &props, flags)); + ifindex = nmtstp_link_dummy_add(NM_PLATFORM_GET, FALSE, "dummy1")->ifindex; + g_assert(nm_platform_link_change(NM_PLATFORM_GET, ifindex, &props, flags)); - link = nmtstp_link_get(NM_PLATFORM_GET, link->ifindex, "dummy1"); + link = nmtstp_link_get(NM_PLATFORM_GET, ifindex, "dummy1"); g_assert(link); g_assert_cmpint(link->link_props.tx_queue_length, ==, 599); g_assert_cmpint(link->link_props.gso_max_size, ==, 10001);