From c2fc74d18a5e65b4a5b30d760550935a174613e8 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 7 Aug 2015 10:49:26 -0400 Subject: [PATCH] osd/ReplicatedPG: fix filter lifecycle in do_osd_ops If we take an error path in [N]PGLS (objects_list_partial error or bad handle) and FAILOK is set we may exec a second filter op that reallocates a new filter without freeing the old one. Simplify by freeing only at the end of the function or when a new filter is (re)allocated. Signed-off-by: Sage Weil --- src/osd/ReplicatedPG.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index e810d48d23e81..4f550acfc068c 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -799,6 +799,10 @@ void ReplicatedPG::do_pg_op(OpRequestRef op) result = -EINVAL; break; } + if (filter) { + delete filter; + filter = NULL; + } result = get_pgls_filter(bp, &filter); if (result < 0) break; @@ -942,8 +946,6 @@ void ReplicatedPG::do_pg_op(OpRequestRef op) dout(10) << " pgnls result=" << result << " outdata.length()=" << osd_op.outdata.length() << dendl; } - delete filter; - filter = NULL; break; case CEPH_OSD_OP_PGLS_FILTER: @@ -956,6 +958,10 @@ void ReplicatedPG::do_pg_op(OpRequestRef op) result = -EINVAL; break; } + if (filter) { + delete filter; + filter = NULL; + } result = get_pgls_filter(bp, &filter); if (result < 0) break; @@ -1091,8 +1097,6 @@ void ReplicatedPG::do_pg_op(OpRequestRef op) dout(10) << " pgls result=" << result << " outdata.length()=" << osd_op.outdata.length() << dendl; } - delete filter; - filter = NULL; break; case CEPH_OSD_OP_PG_HITSET_LS: -- 2.39.5