diff mbox

[2/2] hfsplus: fix potential refcnt problem of nls module

Message ID 1523948733-8537-2-git-send-email-cgxu519@gmx.com (mailing list archive)
State New, archived
Headers show

Commit Message

Chengguang Xu April 17, 2018, 7:05 a.m. UTC
When specifying nls option 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.

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
---
 fs/hfsplus/options.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Viacheslav Dubeyko April 18, 2018, 5:11 p.m. UTC | #1
On Tue, 2018-04-17 at 15:05 +0800, Chengguang Xu wrote:
> When specifying nls option 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.
> 
> Signed-off-by: Chengguang Xu <cgxu519@gmx.com>


Looks good.

Reviewed-by: Vyacheslav Dubeyko <slava@dubeyko.com>

Thanks,
Vyacheslav Dubeyko.


> ---
>  fs/hfsplus/options.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/hfsplus/options.c b/fs/hfsplus/options.c
> index 047e05c..068d4e2 100644
> --- a/fs/hfsplus/options.c
> +++ b/fs/hfsplus/options.c
> @@ -171,8 +171,10 @@ int hfsplus_parse_options(char *input, struct
> hfsplus_sb_info *sbi)
>  				return 0;
>  			}
>  			p = match_strdup(&args[0]);
> -			if (p)
> +			if (p) {
> +				unload_nls(sbi->nls);
>  				sbi->nls = load_nls(p);
> +			}
>  			if (!sbi->nls) {
>  				pr_err("unable to load nls mapping
> \"%s\"\n",
>  				       p);
Andrew Morton April 18, 2018, 7:43 p.m. UTC | #2
On Tue, 17 Apr 2018 15:05:33 +0800 Chengguang Xu <cgxu519@gmx.com> wrote:

> When specifying nls option 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/hfsplus/options.c
> +++ b/fs/hfsplus/options.c
> @@ -171,8 +171,10 @@ int hfsplus_parse_options(char *input, struct hfsplus_sb_info *sbi)
>  				return 0;
>  			}
>  			p = match_strdup(&args[0]);
> -			if (p)
> +			if (p) {
> +				unload_nls(sbi->nls);
>  				sbi->nls = load_nls(p);
> +			}
>  			if (!sbi->nls) {
>  				pr_err("unable to load nls mapping \"%s\"\n",
>  				       p);

Same problem as in [patch 1/2]
diff mbox

Patch

diff --git a/fs/hfsplus/options.c b/fs/hfsplus/options.c
index 047e05c..068d4e2 100644
--- a/fs/hfsplus/options.c
+++ b/fs/hfsplus/options.c
@@ -171,8 +171,10 @@  int hfsplus_parse_options(char *input, struct hfsplus_sb_info *sbi)
 				return 0;
 			}
 			p = match_strdup(&args[0]);
-			if (p)
+			if (p) {
+				unload_nls(sbi->nls);
 				sbi->nls = load_nls(p);
+			}
 			if (!sbi->nls) {
 				pr_err("unable to load nls mapping \"%s\"\n",
 				       p);