From: Sage Weil Date: Wed, 28 Jul 2021 15:45:19 +0000 (-0400) Subject: mon/LogMonitor: fix crash when cluster log file is not writeable X-Git-Tag: v17.1.0~1250^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=addbb8997d5f1fc85812d814ab478fbcb0773b7a;p=ceph.git 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 --- diff --git a/src/mon/LogMonitor.cc b/src/mon/LogMonitor.cc index 96d0a6181db5..e8b41e585e1e 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;