From patchwork Fri Aug 23 01:00:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 11110363 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C116714DB for ; Fri, 23 Aug 2019 01:09:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A8D8E233A0 for ; Fri, 23 Aug 2019 01:09:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387606AbfHWBJf (ORCPT ); Thu, 22 Aug 2019 21:09:35 -0400 Received: from icp-osb-irony-out2.external.iinet.net.au ([203.59.1.155]:5692 "EHLO icp-osb-irony-out2.external.iinet.net.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387641AbfHWBJf (ORCPT ); Thu, 22 Aug 2019 21:09:35 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2DWAQAROl9d/3Wz0XYNWBwBAQEEAQEHBAEBgWeEM4Qgj1YBAQaBEYoRkSMJAQEBAQEBAQEBNwEBhDoDAgKDAjgTAgkBAQEEAQIBAQYDAYVYhhkCAQMjBFIQGA0CJgICRxAGE4UZq1BzfzMaikCBDCiBY4okeIEHgUSDHYdPglgEjxSGD0KVdwmCH5RYDI1bA4pgLYNzo2GBeU0uCoMngk4Xji9ljFYBAQ X-IPAS-Result: A2DWAQAROl9d/3Wz0XYNWBwBAQEEAQEHBAEBgWeEM4Qgj1YBAQaBEYoRkSMJAQEBAQEBAQEBNwEBhDoDAgKDAjgTAgkBAQEEAQIBAQYDAYVYhhkCAQMjBFIQGA0CJgICRxAGE4UZq1BzfzMaikCBDCiBY4okeIEHgUSDHYdPglgEjxSGD0KVdwmCH5RYDI1bA4pgLYNzo2GBeU0uCoMngk4Xji9ljFYBAQ X-IronPort-AV: E=Sophos;i="5.64,419,1559491200"; d="scan'208";a="231796864" Received: from unknown (HELO [192.168.1.222]) ([118.209.179.117]) by icp-osb-irony-out2.iinet.net.au with ESMTP; 23 Aug 2019 09:00:22 +0800 Subject: [PATCH v2 12/15] xfs: mount-api - add xfs_fc_free() From: Ian Kent To: linux-xfs Cc: Dave Chinner , David Howells , Al Viro , Eric Sandeen Date: Fri, 23 Aug 2019 09:00:22 +0800 Message-ID: <156652202212.2607.8621137631843273531.stgit@fedora-28> In-Reply-To: <156652158924.2607.14608448087216437699.stgit@fedora-28> References: <156652158924.2607.14608448087216437699.stgit@fedora-28> User-Agent: StGit/unknown-version MIME-Version: 1.0 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Add the fs_context_operations method .free that performs fs context cleanup on context release. Signed-off-by: Ian Kent --- fs/xfs/xfs_super.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index aae0098fecab..9976163dc537 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -2129,10 +2129,32 @@ static const struct super_operations xfs_super_operations = { .free_cached_objects = xfs_fs_free_cached_objects, }; +static void xfs_fc_free(struct fs_context *fc) +{ + struct xfs_fs_context *ctx = fc->fs_private; + struct xfs_mount *mp = fc->s_fs_info; + + if (mp) { + /* + * If an error occurs before ownership the xfs_mount + * info struct is passed to xfs by the VFS (by assigning + * it to sb->s_fs_info and clearing the corresponding + * fs_context field, which is done before calling fill + * super via .get_tree()) there may be some strings to + * cleanup. + */ + kfree(mp->m_logname); + kfree(mp->m_rtname); + kfree(mp); + } + kfree(ctx); +} + static const struct fs_context_operations xfs_context_ops = { .parse_param = xfs_parse_param, .get_tree = xfs_get_tree, .reconfigure = xfs_reconfigure, + .free = xfs_fc_free, }; static struct file_system_type xfs_fs_type = {