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

Martin Doucha
2023-11-14T12:32:39Z

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