Blame SOURCES/1017-initrd-parse-rd.net.dhcp.vendor-class-rh1870692.patch

d20560
From d15b8c6c561258eb0e0b92d6176a16ccc8c23be3 Mon Sep 17 00:00:00 2001
d20560
From: Antonio Cardace <acardace@redhat.com>
d20560
Date: Thu, 27 Aug 2020 18:18:31 +0200
d20560
Subject: [PATCH 1/4] core: add 'dhcp-vendor-class-identifier' validation
d20560
 function
d20560
d20560
So that it can be reused.
d20560
d20560
Signed-off-by: Antonio Cardace <acardace@redhat.com>
d20560
(cherry picked from commit 5cca669ff39c6909be906e8974e424ffd2ea42c2)
d20560
(cherry picked from commit 847488cb2f9f0ba8017938e0876677180c0c91a0)
d20560
---
d20560
 .../nm-libnm-core-utils.c                     | 55 +++++++++++++++++++
d20560
 .../nm-libnm-core-utils.h                     |  2 +
d20560
 libnm-core/nm-setting-ip4-config.c            | 48 +---------------
d20560
 po/POTFILES.in                                |  1 +
d20560
 src/devices/nm-device.c                       | 11 ++--
d20560
 5 files changed, 65 insertions(+), 52 deletions(-)
d20560
d20560
diff --git a/libnm-core/nm-libnm-core-intern/nm-libnm-core-utils.c b/libnm-core/nm-libnm-core-intern/nm-libnm-core-utils.c
d20560
index f2c85cc60..8be7d913f 100644
d20560
--- a/libnm-core/nm-libnm-core-intern/nm-libnm-core-utils.c
d20560
+++ b/libnm-core/nm-libnm-core-intern/nm-libnm-core-utils.c
d20560
@@ -6,6 +6,8 @@
d20560
 
d20560
 #include "nm-common-macros.h"
d20560
 
d20560
+#include "nm-errors.h"
d20560
+
d20560
 #include <linux/rtnetlink.h>
d20560
 
d20560
 /*****************************************************************************/
d20560
@@ -257,3 +259,56 @@ NM_UTILS_ENUM2STR_DEFINE (nm_utils_route_type2str, guint8,
d20560
 	NM_UTILS_ENUM2STR (RTN_UNREACHABLE, "unreachable"),
d20560
 	NM_UTILS_ENUM2STR (RTN_UNSPEC, "unspecified"),
d20560
 );
d20560
+
d20560
+gboolean
d20560
+nm_utils_validate_dhcp4_vendor_class_id (const char *vci, GError **error)
d20560
+{
d20560
+	const char *  bin;
d20560
+	gsize         unescaped_len;
d20560
+	gs_free char *to_free = NULL;
d20560
+
d20560
+	g_return_val_if_fail (!error || !(*error), FALSE);
d20560
+	g_return_val_if_fail (vci, FALSE);
d20560
+
d20560
+	if (vci[0] == '\0') {
d20560
+		g_set_error_literal (error,
d20560
+		                     NM_CONNECTION_ERROR,
d20560
+		                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
d20560
+		                     _ ("property cannot be an empty string"));
d20560
+		g_prefix_error (error,
d20560
+		                "%s.%s: ",
d20560
+		                NM_SETTING_IP4_CONFIG_SETTING_NAME,
d20560
+		                NM_SETTING_IP4_CONFIG_DHCP_VENDOR_CLASS_IDENTIFIER);
d20560
+		return FALSE;
d20560
+	}
d20560
+
d20560
+	bin = nm_utils_buf_utf8safe_unescape (vci,
d20560
+	                                      NM_UTILS_STR_UTF8_SAFE_FLAG_NONE,
d20560
+	                                      &unescaped_len,
d20560
+	                                      (gpointer *) &to_free);
d20560
+	/* a DHCP option cannot be longer than 255 bytes */
d20560
+	if (unescaped_len > 255) {
d20560
+		g_set_error_literal (error,
d20560
+		                     NM_CONNECTION_ERROR,
d20560
+		                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
d20560
+		                     _ ("property cannot be longer than 255 bytes"));
d20560
+		g_prefix_error (error,
d20560
+		                "%s.%s: ",
d20560
+		                NM_SETTING_IP4_CONFIG_SETTING_NAME,
d20560
+		                NM_SETTING_IP4_CONFIG_DHCP_VENDOR_CLASS_IDENTIFIER);
d20560
+		return FALSE;
d20560
+	}
d20560
+	if (strlen (bin) != unescaped_len) {
d20560
+		g_set_error_literal (error,
d20560
+		                     NM_CONNECTION_ERROR,
d20560
+		                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
d20560
+		                     _ ("property cannot contain any nul bytes"));
d20560
+		g_prefix_error (error,
d20560
+		                "%s.%s: ",
d20560
+		                NM_SETTING_IP4_CONFIG_SETTING_NAME,
d20560
+		                NM_SETTING_IP4_CONFIG_DHCP_VENDOR_CLASS_IDENTIFIER);
d20560
+		return FALSE;
d20560
+	}
d20560
+
d20560
+	return TRUE;
d20560
+}
d20560
diff --git a/libnm-core/nm-libnm-core-intern/nm-libnm-core-utils.h b/libnm-core/nm-libnm-core-intern/nm-libnm-core-utils.h
d20560
index bb3fa5fcf..6c1337d88 100644
d20560
--- a/libnm-core/nm-libnm-core-intern/nm-libnm-core-utils.h
d20560
+++ b/libnm-core/nm-libnm-core-intern/nm-libnm-core-utils.h
d20560
@@ -140,4 +140,6 @@ guint8 nm_utils_route_type_by_name (const char *name);
d20560
 
d20560
 const char *nm_utils_route_type2str (guint8 val, char *buf, gsize len);
d20560
 
d20560
+gboolean nm_utils_validate_dhcp4_vendor_class_id (const char *vci, GError **error);
d20560
+
d20560
 #endif /* __NM_LIBNM_SHARED_UTILS_H__ */
d20560
diff --git a/libnm-core/nm-setting-ip4-config.c b/libnm-core/nm-setting-ip4-config.c
d20560
index 0b8dc89b3..7ffefc25b 100644
d20560
--- a/libnm-core/nm-setting-ip4-config.c
d20560
+++ b/libnm-core/nm-setting-ip4-config.c
d20560
@@ -227,51 +227,9 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
d20560
 		return FALSE;
d20560
 	}
d20560
 
d20560
-	if (priv->dhcp_vendor_class_identifier) {
d20560
-		const char *  bin;
d20560
-		gsize         unescaped_len;
d20560
-		gs_free char *to_free = NULL;
d20560
-
d20560
-		if (priv->dhcp_vendor_class_identifier[0] == '\0') {
d20560
-			g_set_error_literal (error,
d20560
-			                     NM_CONNECTION_ERROR,
d20560
-			                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
d20560
-			                     _ ("property cannot be an empty string"));
d20560
-			g_prefix_error (error,
d20560
-			                "%s.%s: ",
d20560
-			                NM_SETTING_IP4_CONFIG_SETTING_NAME,
d20560
-			                NM_SETTING_IP4_CONFIG_DHCP_VENDOR_CLASS_IDENTIFIER);
d20560
-			return FALSE;
d20560
-		}
d20560
-
d20560
-		bin = nm_utils_buf_utf8safe_unescape (priv->dhcp_vendor_class_identifier,
d20560
-		                                      NM_UTILS_STR_UTF8_SAFE_FLAG_NONE,
d20560
-		                                      &unescaped_len,
d20560
-		                                      (gpointer *) &to_free);
d20560
-		/* a DHCP option cannot be longer than 255 bytes */
d20560
-		if (unescaped_len > 255) {
d20560
-			g_set_error_literal (error,
d20560
-			                     NM_CONNECTION_ERROR,
d20560
-			                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
d20560
-			                     _ ("property cannot be longer than 255 bytes"));
d20560
-			g_prefix_error (error,
d20560
-			                "%s.%s: ",
d20560
-			                NM_SETTING_IP4_CONFIG_SETTING_NAME,
d20560
-			                NM_SETTING_IP4_CONFIG_DHCP_VENDOR_CLASS_IDENTIFIER);
d20560
-			return FALSE;
d20560
-		}
d20560
-		if (strlen (bin) != unescaped_len) {
d20560
-			g_set_error_literal (error,
d20560
-			                     NM_CONNECTION_ERROR,
d20560
-			                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
d20560
-			                     _ ("property cannot contain any nul bytes"));
d20560
-			g_prefix_error (error,
d20560
-			                "%s.%s: ",
d20560
-			                NM_SETTING_IP4_CONFIG_SETTING_NAME,
d20560
-			                NM_SETTING_IP4_CONFIG_DHCP_VENDOR_CLASS_IDENTIFIER);
d20560
-			return FALSE;
d20560
-		}
d20560
-	}
d20560
+	if (   priv->dhcp_vendor_class_identifier
d20560
+	    && !nm_utils_validate_dhcp4_vendor_class_id (priv->dhcp_vendor_class_identifier, error))
d20560
+		return FALSE;
d20560
 
d20560
 	/* Failures from here on are NORMALIZABLE_ERROR... */
d20560
 
d20560
diff --git a/po/POTFILES.in b/po/POTFILES.in
d20560
index 25cb5c4a6..ea2eafa3f 100644
d20560
--- a/po/POTFILES.in
d20560
+++ b/po/POTFILES.in
d20560
@@ -59,6 +59,7 @@ libnm-core/nm-dbus-utils.c
d20560
 libnm-core/nm-keyfile/nm-keyfile-utils.c
d20560
 libnm-core/nm-keyfile/nm-keyfile.c
d20560
 libnm-core/nm-libnm-core-aux/nm-libnm-core-aux.c
d20560
+libnm-core/nm-libnm-core-intern/nm-libnm-core-utils.c
d20560
 libnm-core/nm-setting-6lowpan.c
d20560
 libnm-core/nm-setting-8021x.c
d20560
 libnm-core/nm-setting-adsl.c
d20560
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
d20560
index 72a2b1008..012af4d9a 100644
d20560
--- a/src/devices/nm-device.c
d20560
+++ b/src/devices/nm-device.c
d20560
@@ -8754,7 +8754,6 @@ dhcp4_get_vendor_class_identifier (NMDevice *self, NMSettingIP4Config *s_ip4)
d20560
 {
d20560
 	gs_free char *config_data_prop = NULL;
d20560
 	gs_free char *to_free = NULL;
d20560
-	gboolean validate = FALSE;
d20560
 	const char *conn_prop;
d20560
 	GBytes *bytes = NULL;
d20560
 	const char *bin;
d20560
@@ -8764,12 +8763,14 @@ dhcp4_get_vendor_class_identifier (NMDevice *self, NMSettingIP4Config *s_ip4)
d20560
 
d20560
 	if (!conn_prop) {
d20560
 		/* set in NetworkManager.conf ? */
d20560
-		validate = TRUE;
d20560
 		config_data_prop = nm_config_data_get_connection_default (
d20560
 		    NM_CONFIG_GET_DATA,
d20560
 		    NM_CON_DEFAULT ("ipv4.dhcp-vendor-class-identifier"),
d20560
 		    self);
d20560
-		conn_prop = config_data_prop;
d20560
+
d20560
+		if (   config_data_prop
d20560
+		    && nm_utils_validate_dhcp4_vendor_class_id (config_data_prop, NULL))
d20560
+			conn_prop = config_data_prop;
d20560
 	}
d20560
 
d20560
 	if (conn_prop) {
d20560
@@ -8777,10 +8778,6 @@ dhcp4_get_vendor_class_identifier (NMDevice *self, NMSettingIP4Config *s_ip4)
d20560
 		                                      NM_UTILS_STR_UTF8_SAFE_FLAG_NONE,
d20560
 		                                      &len,
d20560
 		                                      (gpointer *) &to_free);
d20560
-
d20560
-		if (validate && (bin[0] == '\0' || len > 255 || strlen (bin) != len))
d20560
-			return NULL;
d20560
-
d20560
 		if (to_free)
d20560
 			bytes = g_bytes_new_take (g_steal_pointer (&to_free), len);
d20560
 		else
d20560
-- 
d20560
2.26.2
d20560
d20560
d20560
From a491bad06f7c29b257fd948f2149ef80b179da22 Mon Sep 17 00:00:00 2001
d20560
From: Antonio Cardace <acardace@redhat.com>
d20560
Date: Thu, 27 Aug 2020 17:43:54 +0200
d20560
Subject: [PATCH 2/4] initrd: parse 'rd.net.dhcp.vendor-class' kernel cmdline
d20560
 arg
d20560
d20560
This arguments makes NM set the ipv4.dhcp-vendor-class-identifier
d20560
property for all connections.
d20560
d20560
https://bugzilla.redhat.com/show_bug.cgi?id=1872299
d20560
d20560
Signed-off-by: Antonio Cardace <acardace@redhat.com>
d20560
(cherry picked from commit c056cb9306be29a2c194a308b3b6cc639980abe2)
d20560
(cherry picked from commit 15856a4fa20feaae6bd073fc2874180b2a1a335d)
d20560
---
d20560
 src/initrd/nmi-cmdline-reader.c        |  6 ++++
d20560
 src/initrd/tests/test-cmdline-reader.c | 47 ++++++++++++++++++++++++++
d20560
 2 files changed, 53 insertions(+)
d20560
d20560
diff --git a/src/initrd/nmi-cmdline-reader.c b/src/initrd/nmi-cmdline-reader.c
d20560
index be39ef896..ba747b30a 100644
d20560
--- a/src/initrd/nmi-cmdline-reader.c
d20560
+++ b/src/initrd/nmi-cmdline-reader.c
d20560
@@ -28,6 +28,7 @@ typedef struct {
d20560
 	/* Parameters to be set for all connections */
d20560
 	gboolean ignore_auto_dns;
d20560
 	int dhcp_timeout;
d20560
+	char *dhcp4_vci;
d20560
 } Reader;
d20560
 
d20560
 static Reader *
d20560
@@ -52,6 +53,7 @@ reader_destroy (Reader *reader, gboolean free_hash)
d20560
 	g_ptr_array_unref (reader->array);
d20560
 	hash = g_steal_pointer (&reader->hash);
d20560
 	nm_clear_g_free (&reader->hostname);
d20560
+	nm_clear_g_free (&reader->dhcp4_vci);
d20560
 	nm_g_slice_free (reader);
d20560
 	if (!free_hash)
d20560
 		return g_steal_pointer (&hash);
d20560
@@ -95,6 +97,7 @@ reader_create_connection (Reader *reader,
d20560
 	              NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE,
d20560
 	              NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, reader->ignore_auto_dns,
d20560
 	              NM_SETTING_IP_CONFIG_DHCP_TIMEOUT, reader->dhcp_timeout,
d20560
+	              NM_SETTING_IP4_CONFIG_DHCP_VENDOR_CLASS_IDENTIFIER, reader->dhcp4_vci,
d20560
 	              NULL);
d20560
 
d20560
 	setting = nm_setting_ip6_config_new ();
d20560
@@ -927,6 +930,9 @@ nmi_cmdline_reader_parse (const char *sysfs_dir, const char *const*argv, char **
d20560
 		else if (nm_streq (tag, "rd.net.timeout.dhcp")) {
d20560
 			reader->dhcp_timeout = _nm_utils_ascii_str_to_int64 (argument,
d20560
 			                                                     10, 0, G_MAXINT32, 0);
d20560
+		} else if (nm_streq (tag, "rd.net.dhcp.vendor-class")) {
d20560
+			if (nm_utils_validate_dhcp4_vendor_class_id (argument, NULL))
d20560
+				nm_utils_strdup_reset (&reader->dhcp4_vci, argument);
d20560
 		}
d20560
 	}
d20560
 
d20560
diff --git a/src/initrd/tests/test-cmdline-reader.c b/src/initrd/tests/test-cmdline-reader.c
d20560
index 7787cf5ea..a909bc380 100644
d20560
--- a/src/initrd/tests/test-cmdline-reader.c
d20560
+++ b/src/initrd/tests/test-cmdline-reader.c
d20560
@@ -1485,6 +1485,52 @@ test_bootif_off (void)
d20560
 	g_assert_cmpstr (hostname, ==, NULL);
d20560
 }
d20560
 
d20560
+static void
d20560
+test_dhcp_vendor_class_id (void)
d20560
+{
d20560
+	gs_unref_hashtable GHashTable *connections = NULL;
d20560
+	const char *const*ARGV = NM_MAKE_STRV ("rd.net.dhcp.vendor-class=testvci",
d20560
+	                                       "ip=eno1:dhcp");
d20560
+	NMConnection *connection;
d20560
+	NMSettingIP4Config *s_ip4;
d20560
+	gs_free char *hostname = NULL;
d20560
+	gs_free char *vci_long = NULL;
d20560
+	char vci_arg_long[512] = {0};
d20560
+
d20560
+	connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
d20560
+	g_assert (connections);
d20560
+	g_assert_cmpint (g_hash_table_size (connections), ==, 1);
d20560
+	g_assert_cmpstr (hostname, ==, NULL);
d20560
+
d20560
+	connection = g_hash_table_lookup (connections, "eno1");
d20560
+	g_assert (connection);
d20560
+	nmtst_assert_connection_verifies_without_normalization (connection);
d20560
+	s_ip4 = NM_SETTING_IP4_CONFIG (nm_connection_get_setting_ip4_config (connection));
d20560
+	g_assert_cmpstr (nm_setting_ip4_config_get_dhcp_vendor_class_identifier (s_ip4), ==, "testvci");
d20560
+
d20560
+	ARGV = NM_MAKE_STRV ("rd.net.dhcp.vendor-class",
d20560
+	                     "ip=eno1:dhcp");
d20560
+	connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
d20560
+	connection = g_hash_table_lookup (connections, "eno1");
d20560
+	g_assert (connection);
d20560
+	nmtst_assert_connection_verifies_without_normalization (connection);
d20560
+	s_ip4 = NM_SETTING_IP4_CONFIG (nm_connection_get_setting_ip4_config (connection));
d20560
+	g_assert (nm_setting_ip4_config_get_dhcp_vendor_class_identifier (s_ip4) == NULL);
d20560
+
d20560
+
d20560
+
d20560
+	memset (vci_arg_long, 'A', 400);
d20560
+	vci_long = g_strdup_printf ("rd.net.dhcp.vendor-class=%s", vci_arg_long);
d20560
+	ARGV = NM_MAKE_STRV (vci_long,
d20560
+	                     "ip=eno1:dhcp");
d20560
+	connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
d20560
+	connection = g_hash_table_lookup (connections, "eno1");
d20560
+	g_assert (connection);
d20560
+	nmtst_assert_connection_verifies_without_normalization (connection);
d20560
+	s_ip4 = NM_SETTING_IP4_CONFIG (nm_connection_get_setting_ip4_config (connection));
d20560
+	g_assert (nm_setting_ip4_config_get_dhcp_vendor_class_identifier (s_ip4) == NULL);
d20560
+}
d20560
+
d20560
 NMTST_DEFINE ();
d20560
 
d20560
 int main (int argc, char **argv)
d20560
@@ -1521,6 +1567,7 @@ int main (int argc, char **argv)
d20560
 	g_test_add_func ("/initrd/cmdline/bootif/hwtype", test_bootif_hwtype);
d20560
 	g_test_add_func ("/initrd/cmdline/bootif/off", test_bootif_off);
d20560
 	g_test_add_func ("/initrd/cmdline/neednet", test_neednet);
d20560
+	g_test_add_func ("/initrd/cmdline/dhcp/vendor_class_id", test_dhcp_vendor_class_id);
d20560
 
d20560
 	return g_test_run ();
d20560
 }
d20560
-- 
d20560
2.26.2
d20560
d20560
d20560
From bbd77df8ae1cc2510b1ff2c1c27ddf3d907faec3 Mon Sep 17 00:00:00 2001
d20560
From: Antonio Cardace <acardace@redhat.com>
d20560
Date: Tue, 1 Sep 2020 18:38:45 +0200
d20560
Subject: [PATCH 3/4] initrd: fix memory leak
d20560
d20560
Signed-off-by: Antonio Cardace <acardace@redhat.com>
d20560
Fixes: 9f9609555d1c ('initrd: add configuration generator')
d20560
(cherry picked from commit d5c05d07c7aff317284d2d5197d75e0f605b4364)
d20560
(cherry picked from commit bba54613eb4255166c921844e8b6d2a2bd0000a1)
d20560
---
d20560
 shared/nm-glib-aux/nm-macros-internal.h | 8 ++++++++
d20560
 src/initrd/nm-initrd-generator.c        | 2 +-
d20560
 2 files changed, 9 insertions(+), 1 deletion(-)
d20560
d20560
diff --git a/shared/nm-glib-aux/nm-macros-internal.h b/shared/nm-glib-aux/nm-macros-internal.h
d20560
index 15bcd7e58..57ddee050 100644
d20560
--- a/shared/nm-glib-aux/nm-macros-internal.h
d20560
+++ b/shared/nm-glib-aux/nm-macros-internal.h
d20560
@@ -216,6 +216,14 @@ NM_AUTO_DEFINE_FCN0 (GError *, gs_local_free_error, g_error_free)
d20560
 #define gs_unref_keyfile nm_auto(gs_local_keyfile_unref)
d20560
 NM_AUTO_DEFINE_FCN0 (GKeyFile *, gs_local_keyfile_unref, g_key_file_unref)
d20560
 
d20560
+/**
d20560
+ * gs_free_option_context:
d20560
+ *
d20560
+ * Call g_option_context_free() on a variable location when it goes out of scope.
d20560
+ */
d20560
+#define gs_free_option_context nm_auto(gs_local_option_context)
d20560
+NM_AUTO_DEFINE_FCN0 (GOptionContext *, gs_local_option_context, g_option_context_free);
d20560
+
d20560
 /*****************************************************************************/
d20560
 
d20560
 #include "nm-glib.h"
d20560
diff --git a/src/initrd/nm-initrd-generator.c b/src/initrd/nm-initrd-generator.c
d20560
index f984ed739..5a93480bf 100644
d20560
--- a/src/initrd/nm-initrd-generator.c
d20560
+++ b/src/initrd/nm-initrd-generator.c
d20560
@@ -83,7 +83,7 @@ main (int argc, char *argv[])
d20560
 		{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &remaining,       NULL,                                  NULL },
d20560
 		{ NULL }
d20560
 	};
d20560
-	GOptionContext *option_context;
d20560
+	gs_free_option_context GOptionContext *option_context = NULL;
d20560
 	gs_free_error GError *error = NULL;
d20560
 	gs_free char *hostname = NULL;
d20560
 	int errsv;
d20560
-- 
d20560
2.26.2
d20560
d20560
d20560
From 3dec958f413a4566e97183a522afb27b47a9146e Mon Sep 17 00:00:00 2001
d20560
From: Thomas Haller <thaller@redhat.com>
d20560
Date: Thu, 3 Sep 2020 11:35:40 +0200
d20560
Subject: [PATCH 4/4] initrd/tests: fix memleak in test_dhcp_vendor_class_id()
d20560
d20560
Having leaks in the tests, breaks running the test under valgrind. There
d20560
must be no leaks.
d20560
d20560
Fixes: c056cb9306be ('initrd: parse 'rd.net.dhcp.vendor-class' kernel cmdline arg')
d20560
(cherry picked from commit bff23d15d41a42c7b5f43cb3d18d66e7cd289823)
d20560
(cherry picked from commit 5bea8db7ca8fd7520fe605b59e29b974e04b4721)
d20560
Signed-off-by: Antonio Cardace <acardace@redhat.com>
d20560
---
d20560
 src/initrd/tests/test-cmdline-reader.c | 4 +++-
d20560
 1 file changed, 3 insertions(+), 1 deletion(-)
d20560
d20560
diff --git a/src/initrd/tests/test-cmdline-reader.c b/src/initrd/tests/test-cmdline-reader.c
d20560
index a909bc380..a11b76e01 100644
d20560
--- a/src/initrd/tests/test-cmdline-reader.c
d20560
+++ b/src/initrd/tests/test-cmdline-reader.c
d20560
@@ -1508,6 +1508,8 @@ test_dhcp_vendor_class_id (void)
d20560
 	s_ip4 = NM_SETTING_IP4_CONFIG (nm_connection_get_setting_ip4_config (connection));
d20560
 	g_assert_cmpstr (nm_setting_ip4_config_get_dhcp_vendor_class_identifier (s_ip4), ==, "testvci");
d20560
 
d20560
+	nm_clear_pointer (&connections, g_hash_table_unref);
d20560
+
d20560
 	ARGV = NM_MAKE_STRV ("rd.net.dhcp.vendor-class",
d20560
 	                     "ip=eno1:dhcp");
d20560
 	connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
d20560
@@ -1517,7 +1519,7 @@ test_dhcp_vendor_class_id (void)
d20560
 	s_ip4 = NM_SETTING_IP4_CONFIG (nm_connection_get_setting_ip4_config (connection));
d20560
 	g_assert (nm_setting_ip4_config_get_dhcp_vendor_class_identifier (s_ip4) == NULL);
d20560
 
d20560
-
d20560
+	nm_clear_pointer (&connections, g_hash_table_unref);
d20560
 
d20560
 	memset (vci_arg_long, 'A', 400);
d20560
 	vci_long = g_strdup_printf ("rd.net.dhcp.vendor-class=%s", vci_arg_long);
d20560
-- 
d20560
2.26.2
d20560