From addbb8997d5f1fc85812d814ab478fbcb0773b7a Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 28 Jul 2021 11:45:19 -0400 Subject: [PATCH] mon/LogMonitor: fix crash when cluster log file is not writeable If we are in this block, then p == channel_fds.end() and p->first is not valid. Also, no need to populate channel_fds with an fd of -1. Fixes: https://tracker.ceph.com/issues/51816 Signed-off-by: Sage Weil --- src/mon/LogMonitor.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mon/LogMonitor.cc b/src/mon/LogMonitor.cc index 96d0a6181db..e8b41e585e1 100644 --- a/src/mon/LogMonitor.cc +++ b/src/mon/LogMonitor.cc @@ -400,9 +400,10 @@ void LogMonitor::log_external(const LogEntry& le) if (fd < 0) { int err = -errno; dout(1) << "unable to write to '" << log_file << "' for channel '" - << p->first << "': " << cpp_strerror(err) << dendl; + << channel << "': " << cpp_strerror(err) << dendl; + } else { + channel_fds[channel] = fd; } - channel_fds[channel] = fd; } } else { fd = p->second; -- 2.47.3