From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A41E3C433E2 for ; Thu, 25 Mar 2021 00:09:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6BC2C61A25 for ; Thu, 25 Mar 2021 00:09:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239133AbhCYAIn (ORCPT ); Wed, 24 Mar 2021 20:08:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234902AbhCYAIi (ORCPT ); Wed, 24 Mar 2021 20:08:38 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0F97C06174A; Wed, 24 Mar 2021 17:08:38 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: shreeya) with ESMTPSA id 4D85F1F45F0B From: Shreeya Patel To: tytso@mit.edu, adilger.kernel@dilger.ca, jaegeuk@kernel.org, chao@kernel.org, krisman@collabora.com, ebiggers@google.com, drosen@google.com, ebiggers@kernel.org, yuchao0@huawei.com Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, kernel@collabora.com, andre.almeida@collabora.com Subject: [PATCH v4 2/5] fs: Check if utf8 encoding is loaded before calling utf8_unload() Date: Thu, 25 Mar 2021 05:38:08 +0530 Message-Id: <20210325000811.1379641-3-shreeya.patel@collabora.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210325000811.1379641-1-shreeya.patel@collabora.com> References: <20210325000811.1379641-1-shreeya.patel@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org utf8_unload is being called if CONFIG_UNICODE is enabled. The ifdef block doesn't check if utf8 encoding has been loaded or not before calling the utf8_unload() function. This is not the expected behavior since it would sometimes lead to unloading utf8 even before loading it. Hence, add a condition which will check if sb->encoding is NOT NULL before calling the utf8_unload(). Reviewed-by: Gabriel Krisman Bertazi Signed-off-by: Shreeya Patel --- fs/ext4/super.c | 6 ++++-- fs/f2fs/super.c | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index ad34a37278cd..e438d14f9a87 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1259,7 +1259,8 @@ static void ext4_put_super(struct super_block *sb) fs_put_dax(sbi->s_daxdev); fscrypt_free_dummy_policy(&sbi->s_dummy_enc_policy); #ifdef CONFIG_UNICODE - utf8_unload(sb->s_encoding); + if (sb->s_encoding) + utf8_unload(sb->s_encoding); #endif kfree(sbi); } @@ -5165,7 +5166,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) crypto_free_shash(sbi->s_chksum_driver); #ifdef CONFIG_UNICODE - utf8_unload(sb->s_encoding); + if (sb->s_encoding) + utf8_unload(sb->s_encoding); #endif #ifdef CONFIG_QUOTA diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 7069793752f1..0a04983c294e 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1430,7 +1430,8 @@ static void f2fs_put_super(struct super_block *sb) for (i = 0; i < NR_PAGE_TYPE; i++) kvfree(sbi->write_io[i]); #ifdef CONFIG_UNICODE - utf8_unload(sb->s_encoding); + if (sb->s_encoding) + utf8_unload(sb->s_encoding); #endif kfree(sbi); } @@ -4073,8 +4074,10 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) kvfree(sbi->write_io[i]); #ifdef CONFIG_UNICODE - utf8_unload(sb->s_encoding); - sb->s_encoding = NULL; + if (sb->s_encoding) { + utf8_unload(sb->s_encoding); + sb->s_encoding = NULL; + } #endif free_options: #ifdef CONFIG_QUOTA -- 2.30.1