Skip to contentSkip to conversation

ubifs: fix to check error code of register_shrinker

PATCH Applied Chao Yu 3 participants 5 messages May 18, 2015 – Jun 2, 2015

Subsystems (2)
lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 1/1 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.

---
 fs/ubifs/super.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/ubifs/super.c +4 -1
index 75e6f04..fa83d1b 100644
@@ -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;
 }
Signature · 1 line
2.3.3
author
#1 lore raw

Ping.

Add Cc Richard Weinberger.

Quoted 47 lines

-----Original Message-----
From: linux-mtd [mailto:[email protected]] On Behalf Of Chao Yu
Sent: Monday, May 18, 2015 4:43 PM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]
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.

---
 fs/ubifs/super.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/ubifs/super.c +4 -2
index 75e6f04..fa83d1b 100644
@@ -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/

#2 lore raw

Am 26.05.2015 um 13:23 schrieb Chao Yu:

Quoted 3 lines

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

Quoted 48 lines
Quoted 47 lines

-----Original Message-----
From: linux-mtd [mailto:[email protected]] On Behalf Of Chao Yu
Sent: Monday, May 18, 2015 4:43 PM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]
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.

---
 fs/ubifs/super.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/ubifs/super.c +4 -2
index 75e6f04..fa83d1b 100644
@@ -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/

#3 lore raw
Quoted 7 lines · Richard Weinberger

Am 26.05.2015 um 13:23 schrieb Chao Yu:

Quoted 3 lines

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!

maintainer Applied
#4 lore raw

Am 27.05.2015 um 09:27 schrieb Artem Bityutskiy:

Quoted 10 lines · Richard Weinberger
Quoted 7 lines

Am 26.05.2015 um 13:23 schrieb Chao Yu:

Quoted 3 lines

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