linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ubifs: fix to check error code of register_shrinker
@ 2015-05-18  8:43 Chao Yu
  2015-05-26 11:23 ` Chao Yu
  0 siblings, 1 reply; 5+ messages in thread
From: Chao Yu @ 2015-05-18  8:43 UTC (permalink / raw)
  To: dedekind1, adrian.hunter; +Cc: linux-mtd, linux-kernel

register_shrinker() in ubifs_init() can fail due to fail to call kzalloc.
This patch fixes to check the return value of register_shrinker, otherwise
our shrinker may be unregistered after ubifs initialized successfully.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
---
 fs/ubifs/super.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 75e6f04..fa83d1b 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -2245,7 +2245,9 @@ static int __init ubifs_init(void)
 	if (!ubifs_inode_slab)
 		return -ENOMEM;
 
-	register_shrinker(&ubifs_shrinker_info);
+	err = register_shrinker(&ubifs_shrinker_info);
+	if (err)
+		goto out_slab;
 
 	err = ubifs_compressors_init();
 	if (err)
@@ -2269,6 +2271,7 @@ out_compr:
 	ubifs_compressors_exit();
 out_shrinker:
 	unregister_shrinker(&ubifs_shrinker_info);
+out_slab:
 	kmem_cache_destroy(ubifs_inode_slab);
 	return err;
 }
-- 
2.3.3



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [PATCH] ubifs: fix to check error code of register_shrinker
  2015-05-18  8:43 [PATCH] ubifs: fix to check error code of register_shrinker Chao Yu
@ 2015-05-26 11:23 ` Chao Yu
  2015-05-26 11:29   ` Richard Weinberger
  0 siblings, 1 reply; 5+ messages in thread
From: Chao Yu @ 2015-05-26 11:23 UTC (permalink / raw)
  To: dedekind1, adrian.hunter, richard; +Cc: linux-mtd, linux-kernel

Ping.

Add Cc Richard Weinberger.

> -----Original Message-----
> From: linux-mtd [mailto:linux-mtd-bounces@lists.infradead.org] On Behalf Of Chao Yu
> Sent: Monday, May 18, 2015 4:43 PM
> To: dedekind1@gmail.com; adrian.hunter@intel.com
> Cc: linux-mtd@lists.infradead.org; linux-kernel@vger.kernel.org
> Subject: [PATCH] ubifs: fix to check error code of register_shrinker
> 
> register_shrinker() in ubifs_init() can fail due to fail to call kzalloc.
> This patch fixes to check the return value of register_shrinker, otherwise
> our shrinker may be unregistered after ubifs initialized successfully.
> 
> Signed-off-by: Chao Yu <chao2.yu@samsung.com>
> ---
>  fs/ubifs/super.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
> index 75e6f04..fa83d1b 100644
> --- a/fs/ubifs/super.c
> +++ b/fs/ubifs/super.c
> @@ -2245,7 +2245,9 @@ static int __init ubifs_init(void)
>  	if (!ubifs_inode_slab)
>  		return -ENOMEM;
> 
> -	register_shrinker(&ubifs_shrinker_info);
> +	err = register_shrinker(&ubifs_shrinker_info);
> +	if (err)
> +		goto out_slab;
> 
>  	err = ubifs_compressors_init();
>  	if (err)
> @@ -2269,6 +2271,7 @@ out_compr:
>  	ubifs_compressors_exit();
>  out_shrinker:
>  	unregister_shrinker(&ubifs_shrinker_info);
> +out_slab:
>  	kmem_cache_destroy(ubifs_inode_slab);
>  	return err;
>  }
> --
> 2.3.3
> 
> 
> 
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ubifs: fix to check error code of register_shrinker
  2015-05-26 11:23 ` Chao Yu
@ 2015-05-26 11:29   ` Richard Weinberger
  2015-05-27  7:27     ` Artem Bityutskiy
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Weinberger @ 2015-05-26 11:29 UTC (permalink / raw)
  To: Chao Yu, dedekind1, adrian.hunter; +Cc: linux-mtd, linux-kernel

Am 26.05.2015 um 13:23 schrieb Chao Yu:
> Ping.
> 
> Add Cc Richard Weinberger.

Patch looks good to me.
Artem, if you don't mind I'd pick it up for the 4.2 queue.

Thanks,
//richard

>> -----Original Message-----
>> From: linux-mtd [mailto:linux-mtd-bounces@lists.infradead.org] On Behalf Of Chao Yu
>> Sent: Monday, May 18, 2015 4:43 PM
>> To: dedekind1@gmail.com; adrian.hunter@intel.com
>> Cc: linux-mtd@lists.infradead.org; linux-kernel@vger.kernel.org
>> Subject: [PATCH] ubifs: fix to check error code of register_shrinker
>>
>> register_shrinker() in ubifs_init() can fail due to fail to call kzalloc.
>> This patch fixes to check the return value of register_shrinker, otherwise
>> our shrinker may be unregistered after ubifs initialized successfully.
>>
>> Signed-off-by: Chao Yu <chao2.yu@samsung.com>
>> ---
>>  fs/ubifs/super.c | 5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
>> index 75e6f04..fa83d1b 100644
>> --- a/fs/ubifs/super.c
>> +++ b/fs/ubifs/super.c
>> @@ -2245,7 +2245,9 @@ static int __init ubifs_init(void)
>>  	if (!ubifs_inode_slab)
>>  		return -ENOMEM;
>>
>> -	register_shrinker(&ubifs_shrinker_info);
>> +	err = register_shrinker(&ubifs_shrinker_info);
>> +	if (err)
>> +		goto out_slab;
>>
>>  	err = ubifs_compressors_init();
>>  	if (err)
>> @@ -2269,6 +2271,7 @@ out_compr:
>>  	ubifs_compressors_exit();
>>  out_shrinker:
>>  	unregister_shrinker(&ubifs_shrinker_info);
>> +out_slab:
>>  	kmem_cache_destroy(ubifs_inode_slab);
>>  	return err;
>>  }
>> --
>> 2.3.3
>>
>>
>>
>> ______________________________________________________
>> Linux MTD discussion mailing list
>> http://lists.infradead.org/mailman/listinfo/linux-mtd/
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ubifs: fix to check error code of register_shrinker
  2015-05-26 11:29   ` Richard Weinberger
@ 2015-05-27  7:27     ` Artem Bityutskiy
  2015-06-02  9:42       ` Richard Weinberger
  0 siblings, 1 reply; 5+ messages in thread
From: Artem Bityutskiy @ 2015-05-27  7:27 UTC (permalink / raw)
  To: Richard Weinberger; +Cc: Chao Yu, adrian.hunter, linux-mtd, linux-kernel

On Tue, 2015-05-26 at 13:29 +0200, Richard Weinberger wrote:
> Am 26.05.2015 um 13:23 schrieb Chao Yu:
> > Ping.
> > 
> > Add Cc Richard Weinberger.
> 
> Patch looks good to me.
> Artem, if you don't mind I'd pick it up for the 4.2 queue.

Yes, please, thanks!

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ubifs: fix to check error code of register_shrinker
  2015-05-27  7:27     ` Artem Bityutskiy
@ 2015-06-02  9:42       ` Richard Weinberger
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Weinberger @ 2015-06-02  9:42 UTC (permalink / raw)
  To: dedekind1; +Cc: Chao Yu, adrian.hunter, linux-mtd, linux-kernel

Am 27.05.2015 um 09:27 schrieb Artem Bityutskiy:
> On Tue, 2015-05-26 at 13:29 +0200, Richard Weinberger wrote:
>> Am 26.05.2015 um 13:23 schrieb Chao Yu:
>>> Ping.
>>>
>>> Add Cc Richard Weinberger.
>>
>> Patch looks good to me.
>> Artem, if you don't mind I'd pick it up for the 4.2 queue.
> 
> Yes, please, thanks!

Applied!

Thanks,
//richard

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-06-02  9:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-18  8:43 [PATCH] ubifs: fix to check error code of register_shrinker Chao Yu
2015-05-26 11:23 ` Chao Yu
2015-05-26 11:29   ` Richard Weinberger
2015-05-27  7:27     ` Artem Bityutskiy
2015-06-02  9:42       ` Richard Weinberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).