From 5be3d2fe4040d46b37982b9d598c1602765b65ae Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Sat, 30 Nov 2024 00:22:30 +0530 Subject: [PATCH] mds: Fix invalid access of mdr->dn[0].back() See https://github.com/ceph/ceph/pull/31534 for a similar fix. Fixes: https://tracker.ceph.com/issues/69059 Signed-off-by: Anoop C S (cherry picked from commit d2386e80bb25bd70c864c0954ce84718019ab955) --- src/mds/Server.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 23cf5a9f39c..5b7454c9292 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -4121,7 +4121,7 @@ void Server::handle_client_getattr(const MDRequestRef& mdr, bool is_lookup) if (r < 0) { // fall-thru. let rdlock_path_pin_ref() check again. - } else if (is_lookup) { + } else if (is_lookup && mdr->dn[0].size()) { CDentry* dn = mdr->dn[0].back(); mdr->pin(dn); auto em = dn->batch_ops.emplace(std::piecewise_construct, std::forward_as_tuple(mask), std::forward_as_tuple()); @@ -4226,7 +4226,7 @@ void Server::handle_client_getattr(const MDRequestRef& mdr, bool is_lookup) // reply dout(10) << "reply to stat on " << *req << dendl; mdr->tracei = ref; - if (is_lookup) + if (is_lookup && mdr->dn[0].size()) mdr->tracedn = mdr->dn[0].back(); respond_to_request(mdr, 0); } -- 2.39.5