From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net ([212.227.17.20]:55341 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752634AbeDSBSt (ORCPT ); Wed, 18 Apr 2018 21:18:49 -0400 Content-Type: text/plain; charset=gb2312 Mime-Version: 1.0 (Mac OS X Mail 11.3 \(3445.6.18\)) Subject: Re: [PATCH 1/2] hfs: fix potential refcnt problem of nls module From: "cgxu519@gmx.com" In-Reply-To: <20180418124251.d66a36cb23673f0d8b152910@linux-foundation.org> Date: Thu, 19 Apr 2018 09:18:53 +0800 Cc: "cgxu519@gmx.com" , linux-fsdevel@vger.kernel.org, dhowells@redhat.com, kstewart@linuxfoundation.org, gregkh@linuxfoundation.org, tglx@linutronix.de, pombredanne@nexb.com, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <060F1E17-ECD0-41F5-B635-2A0E16967433@gmx.com> References: <1523948733-8537-1-git-send-email-cgxu519@gmx.com> <20180418124251.d66a36cb23673f0d8b152910@linux-foundation.org> To: Andrew Morton Sender: linux-fsdevel-owner@vger.kernel.org List-ID: �� 2018��4��19�գ�����3:42��Andrew Morton д���� > > On Tue, 17 Apr 2018 15:05:32 +0800 Chengguang Xu wrote: > >> When specifying iocharset/codepage multiple times in a mount, >> current option parsing will cause inaccurate refcount of nls >> module. Hence, call unload_nls for previous one in this case. >> >> ... >> >> --- a/fs/hfs/super.c >> +++ b/fs/hfs/super.c >> @@ -329,8 +329,10 @@ static int parse_options(char *options, struct hfs_sb_info *hsb) >> return 0; >> } >> p = match_strdup(&args[0]); >> - if (p) >> + if (p) { >> + unload_nls(hsb->nls_disk); >> hsb->nls_disk = load_nls(p); >> + } >> if (!hsb->nls_disk) { >> pr_err("unable to load codepage \"%s\"\n", p); >> kfree(p); >> @@ -344,8 +346,10 @@ static int parse_options(char *options, struct hfs_sb_info *hsb) >> return 0; >> } >> p = match_strdup(&args[0]); >> - if (p) >> + if (p) { >> + unload_nls(hsb->nls_io); >> hsb->nls_io = load_nls(p); >> + } >> if (!hsb->nls_io) { >> pr_err("unable to load iocharset \"%s\"\n", p); >> kfree(p); > > Confused. > > break; > : case opt_codepage: > : if (hsb->nls_disk) { > : pr_err("unable to change codepage\n"); > : return 0; > : } > > Here, hsb->nls_disk is known to be zero. > > : p = match_strdup(&args[0]); > : if (p) { > : unload_nls(hsb->nls_disk); > > So this will always do unload_nls(0). > > : hsb->nls_disk = load_nls(p); > : } > > And the same applies to your opt_iocharset change. You are right. Sorry I just misread this part, please just drop the patch. Thanks.