From 59ee9d2a796ea9ad4fc55ee5df69fd6b0218a887 Mon Sep 17 00:00:00 2001 From: Martin Buck Date: Mon, 6 Jan 2025 15:35:30 +0100 Subject: [PATCH] lib: Handle call to zlog_5424_cycle() without valid FD properly In zlog_5424_cycle(), struct zlt_5424 *zlt only points to valid memory when the passed file descriptor is >= 0 (and passing -1 seems to be a supported use case). So we shouldn't try to compute the address of its zt member when zlt is NULL. Signed-off-by: Martin Buck --- lib/zlog_5424.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/zlog_5424.c b/lib/zlog_5424.c index c8586a1a02..6265ce3b1f 100644 --- a/lib/zlog_5424.c +++ b/lib/zlog_5424.c @@ -782,7 +782,7 @@ static void zlog_5424_cycle(struct zlog_cfg_5424 *zcf, int fd) } old = zcf->active ? &zcf->active->zt : NULL; - old = zlog_target_replace(old, &zlt->zt); + old = zlog_target_replace(old, zlt ? &zlt->zt : NULL); zcf->active = zlt; /* oldt->fd == fd happens for zlog_5424_apply_meta() */