[LTP] [PATCH v2 2/5] tst_netlink_destroy_context(): Allow safely passing NULL context
Martin Doucha
mdoucha@suse.cz
Tue Nov 14 13:31:23 CET 2023
Signed-off-by: Martin Doucha <mdoucha@suse.cz>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
---
Changes since v1: None
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