lib: Prevent Pointer dereference to NULL

The call into zlog_target_clone was passing
&zcf->active->zt.  From running memory sanitizer
we are seeing that it is complaining about
member access within null pointer of type...
for this value.  Since the call into zlog_target_clone
checks for NULL for this value, let's just make sure
we don't do anything stupid here.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2024-05-22 20:35:57 -04:00
parent f5d6b6bf9b
commit b4c884b9ae
2 changed files with 6 additions and 4 deletions

View file

@ -742,7 +742,8 @@ static void zlog_5424_cycle(struct zlog_cfg_5424 *zcf, int fd)
/* all of this is swapped in by zlog_target_replace() below,
* the old target is RCU-freed afterwards.
*/
zt = zlog_target_clone(MTYPE_LOG_5424, &zcf->active->zt,
zt = zlog_target_clone(MTYPE_LOG_5424,
zcf->active ? &zcf->active->zt : NULL,
sizeof(*zlt));
zlt = container_of(zt, struct zlt_5424, zt);

View file

@ -208,7 +208,8 @@ static bool zlog_file_cycle(struct zlog_cfg_file *zcf)
break;
}
zt = zlog_target_clone(MTYPE_LOG_FD, &zcf->active->zt,
zt = zlog_target_clone(MTYPE_LOG_FD,
zcf->active ? &zcf->active->zt : NULL,
sizeof(*zlt));
zlt = container_of(zt, struct zlt_fd, zt);
@ -551,7 +552,7 @@ void zlog_syslog_set_prio_min(int prio_min)
if (syslog_prio_min != ZLOG_DISABLED) {
newztc = zlog_target_clone(MTYPE_LOG_SYSL,
&zlt_syslog->zt,
zlt_syslog ? &zlt_syslog->zt : NULL,
sizeof(*newzt));
newzt = container_of(newztc, struct zlt_syslog, zt);
newzt->zt.prio_min = prio_min;
@ -561,7 +562,7 @@ void zlog_syslog_set_prio_min(int prio_min)
}
zlog_target_free(MTYPE_LOG_SYSL,
zlog_target_replace(&zlt_syslog->zt,
zlog_target_replace(zlt_syslog ? &zlt_syslog->zt : NULL,
&newzt->zt));
zlt_syslog = newzt;