[LTP] [PATCH 2/3] tst_netlink_destroy_context(): Allow safely passing NULL context

Martin Doucha mdoucha@suse.cz
Fri Oct 13 17:17:15 CEST 2023


Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
 lib/tst_rtnetlink.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/tst_rtnetlink.c b/lib/tst_rtnetlink.c
index eacfdced1..bf782ffb5 100644
--- a/lib/tst_rtnetlink.c
+++ b/lib/tst_rtnetlink.c
@@ -55,6 +55,9 @@ static int netlink_grow_buffer(const char *file, const int lineno,
 void tst_netlink_destroy_context(const char *file, const int lineno,
 	struct tst_netlink_context *ctx)
 {
+	if (!ctx)
+		return;
+
 	safe_close(file, lineno, NULL, ctx->socket);
 	free(ctx->buffer);
 	free(ctx);
-- 
2.42.0



More information about the ltp mailing list