From nobody Sat Feb 7 17:55:02 2026 Received: from out-185.mta0.migadu.com (out-185.mta0.migadu.com [91.218.175.185]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9655D13B592 for ; Mon, 19 Aug 2024 09:52:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.185 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724061151; cv=none; b=Z4rPXjBEvO4NC3vgCaUUgzhqhXQN27TPOBH6OkSgiUrWGTA6tBhEwyd3AhH7LMsULQzIQyGxxpeFBVijBHpOkgJdR5nfi1L7hIJSblHL5JKYp8w+r0Miagm3/Kp2Sao5ENiXTfQlmve4Fu5sMVJtaqfzuTaIsTT1KtKptQys3O8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724061151; c=relaxed/simple; bh=4BN2Ul/ProVikPdBhbEcsEIXJ7jcB8IUaOeJDhhh7VQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=fz6/t7s6ej4guYAimzJzjwVmOIcYHdjvHUBRAKwb9v+96piuBwz75u5bypfK29ORrgEq0EDUgBmcxAkXYAciyr7/VUt6UUYzxfMTXXv9nH7NJi+bWM+WwUWWHtkSlmezmbu8dWrN28nJdymeobO603nrEZuQ6oKN1oIO5D4U6is= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=L4EMZDPZ; arc=none smtp.client-ip=91.218.175.185 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="L4EMZDPZ" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1724061146; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=tqrN5CJi6NpTChGvwEbegOzVx3UaFOTDcMpyKEfmAB4=; b=L4EMZDPZ6r54KD0ST93Epem3R2vBzFeH1ragumTt6IBfmLD9G06d/c4KMHy6bvtYwLkTZ9 5O3TpHgOkIursqHX3LALvughQb1aqJhuS+Wm3AV7d8hxEs9k1p5o/XdW8DW2HSoGXDftlr vr/J7ESw1TiR6jL535mlZ6WwuhjRct4= From: "Luis Henriques (SUSE)" To: Xiubo Li , Ilya Dryomov , Milind Changire Cc: ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, "Luis Henriques (SUSE)" Subject: [PATCH v2] ceph: fix memory in MDS client cap_auths Date: Mon, 19 Aug 2024 10:52:17 +0100 Message-ID: <20240819095217.6415-1-luis.henriques@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" The cap_auths that are allocated during an MDS session opening are never released, causing a memory leak detected by kmemleak. Fix this by freeing the memory allocated when shutting down the mds client. Fixes: 1d17de9534cb ("ceph: save cap_auths in MDS client when session is op= ened") Signed-off-by: Luis Henriques (SUSE) Reviewed-by: Xiubo Li --- Changes since v1: * dropped mdsc->mutex locking as we don't need it at this point fs/ceph/mds_client.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 276e34ab3e2c..2e4b3ee7446c 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -6015,6 +6015,18 @@ static void ceph_mdsc_stop(struct ceph_mds_client *m= dsc) ceph_mdsmap_destroy(mdsc->mdsmap); kfree(mdsc->sessions); ceph_caps_finalize(mdsc); + + if (mdsc->s_cap_auths) { + int i; + + for (i =3D 0; i < mdsc->s_cap_auths_num; i++) { + kfree(mdsc->s_cap_auths[i].match.gids); + kfree(mdsc->s_cap_auths[i].match.path); + kfree(mdsc->s_cap_auths[i].match.fs_name); + } + kfree(mdsc->s_cap_auths); + } + ceph_pool_perm_destroy(mdsc); }