OpenVZ Forum


Home » Mailing lists » Devel » [PATCH] ext3: fix ext34_fill_super group description initialization
[PATCH] ext3: fix ext34_fill_super group description initialization [message #15786] Mon, 13 August 2007 09:09 Go to next message
Dmitriy Monakhov is currently offline  Dmitriy Monakhov
Messages: 52
Registered: October 2006
Member
->s_group_desc have to be zero filled because if sb_read() failed
we jump to following error path.
failed_mount2:
	for (i = 0; i < db_count; i++)
		brelse(sbi->s_group_desc[i]);<< Bad things may happen here

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 fs/ext3/super.c |    2 +-
 fs/ext4/super.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index f8ac18f..208738e 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -1718,7 +1718,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
 				       / EXT3_BLOCKS_PER_GROUP(sb)) + 1;
 	db_count = (sbi->s_groups_count + EXT3_DESC_PER_BLOCK(sb) - 1) /
 		   EXT3_DESC_PER_BLOCK(sb);
-	sbi->s_group_desc = kmalloc(db_count * sizeof (struct buffer_head *),
+	sbi->s_group_desc = kzalloc(db_count * sizeof (struct buffer_head *),
 				    GFP_KERNEL);
 	if (sbi->s_group_desc == NULL) {
 		printk (KERN_ERR "EXT3-fs: not enough memory\n");
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 8f1d2f6..fefffc0 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1830,7 +1830,7 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
 	sbi->s_groups_count = blocks_count;
 	db_count = (sbi->s_groups_count + EXT4_DESC_PER_BLOCK(sb) - 1) /
 		   EXT4_DESC_PER_BLOCK(sb);
-	sbi->s_group_desc = kmalloc(db_count * sizeof (struct buffer_head *),
+	sbi->s_group_desc = kzalloc(db_count * sizeof (struct buffer_head *),
 				    GFP_KERNEL);
 	if (sbi->s_group_desc == NULL) {
 		printk (KERN_ERR "EXT4-fs: not enough memory\n");
-- 
1.5.2.2
Re: [PATCH] ext3: fix ext34_fill_super group description initialization [message #15787 is a reply to message #15786] Mon, 13 August 2007 09:24 Go to previous messageGo to next message
Dmitry Monakhov is currently offline  Dmitry Monakhov
Messages: 4
Registered: June 2007
Junior Member
On 13:09 Mon 13 Aug     , Dmitry Monakhov wrote:
> ->s_group_desc have to be zero filled because if sb_read() failed
> we jump to following error path.
> failed_mount2:
> 	for (i = 0; i < db_count; i++)
> 		brelse(sbi->s_group_desc[i]);<< Bad things may happen here
OOPs i'm sorry. I've lost db_count changing after sb_read() error,
so error path is ok, and this patch is not needed.
> 
> Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
> ---
>  fs/ext3/super.c |    2 +-
>  fs/ext4/super.c |    2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/ext3/super.c b/fs/ext3/super.c
> index f8ac18f..208738e 100644
> --- a/fs/ext3/super.c
> +++ b/fs/ext3/super.c
> @@ -1718,7 +1718,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
>  				       / EXT3_BLOCKS_PER_GROUP(sb)) + 1;
>  	db_count = (sbi->s_groups_count + EXT3_DESC_PER_BLOCK(sb) - 1) /
>  		   EXT3_DESC_PER_BLOCK(sb);
> -	sbi->s_group_desc = kmalloc(db_count * sizeof (struct buffer_head *),
> +	sbi->s_group_desc = kzalloc(db_count * sizeof (struct buffer_head *),
>  				    GFP_KERNEL);
>  	if (sbi->s_group_desc == NULL) {
>  		printk (KERN_ERR "EXT3-fs: not enough memory\n");
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 8f1d2f6..fefffc0 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -1830,7 +1830,7 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
>  	sbi->s_groups_count = blocks_count;
>  	db_count = (sbi->s_groups_count + EXT4_DESC_PER_BLOCK(sb) - 1) /
>  		   EXT4_DESC_PER_BLOCK(sb);
> -	sbi->s_group_desc = kmalloc(db_count * sizeof (struct buffer_head *),
> +	sbi->s_group_desc = kzalloc(db_count * sizeof (struct buffer_head *),
>  				    GFP_KERNEL);
>  	if (sbi->s_group_desc == NULL) {
>  		printk (KERN_ERR "EXT4-fs: not enough memory\n");
> -- 
> 1.5.2.2
> 
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Re: [PATCH] ext3: fix ext34_fill_super group description initialization [message #15860 is a reply to message #15786] Mon, 13 August 2007 09:20 Go to previous messageGo to next message
aneesh.kumar is currently offline  aneesh.kumar
Messages: 1
Registered: August 2007
Junior Member
Dmitry Monakhov wrote:
> ->s_group_desc have to be zero filled because if sb_read() failed
> we jump to following error path.
> failed_mount2:
> 	for (i = 0; i < db_count; i++)
> 		brelse(sbi->s_group_desc[i]);<< Bad things may happen here
> 


But the db_count is updated in the failure path to point to the number
of successful sb_read. 

-aneesh
Re: [PATCH] ext3: fix ext34_fill_super group description initialization [message #15861 is a reply to message #15786] Mon, 13 August 2007 13:19 Go to previous message
Mariusz Kozlowski is currently offline  Mariusz Kozlowski
Messages: 1
Registered: August 2007
Junior Member
> ->s_group_desc have to be zero filled because if sb_read() failed
> we jump to following error path.
> failed_mount2:
> 	for (i = 0; i < db_count; i++)
> 		brelse(sbi->s_group_desc[i]);<< Bad things may happen here
>
> Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
> ---
>  fs/ext3/super.c |    2 +-
>  fs/ext4/super.c |    2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ext3/super.c b/fs/ext3/super.c
> index f8ac18f..208738e 100644
> --- a/fs/ext3/super.c
> +++ b/fs/ext3/super.c
> @@ -1718,7 +1718,7 @@ static int ext3_fill_super (struct super_block *sb,
> void *data, int silent) / EXT3_BLOCKS_PER_GROUP(sb)) + 1;
>  	db_count = (sbi->s_groups_count + EXT3_DESC_PER_BLOCK(sb) - 1) /
>  		   EXT3_DESC_PER_BLOCK(sb);
> -	sbi->s_group_desc = kmalloc(db_count * sizeof (struct buffer_head *),
> +	sbi->s_group_desc = kzalloc(db_count * sizeof (struct buffer_head *),
>  				    GFP_KERNEL);

kcalloc?

>  	if (sbi->s_group_desc == NULL) {
>  		printk (KERN_ERR "EXT3-fs: not enough memory\n");
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 8f1d2f6..fefffc0 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -1830,7 +1830,7 @@ static int ext4_fill_super (struct super_block *sb,
> void *data, int silent) sbi->s_groups_count = blocks_count;
>  	db_count = (sbi->s_groups_count + EXT4_DESC_PER_BLOCK(sb) - 1) /
>  		   EXT4_DESC_PER_BLOCK(sb);
> -	sbi->s_group_desc = kmalloc(db_count * sizeof (struct buffer_head *),
> +	sbi->s_group_desc = kzalloc(db_count * sizeof (struct buffer_head *),
>  				    GFP_KERNEL);

kcalloc?

>  	if (sbi->s_group_desc == NULL) {
>  		printk (KERN_ERR "EXT4-fs: not enough memory\n");

Regards,

	Mariusz
Previous Topic: [PATCH 3/20] Introduce MS_KERNMOUNT flag
Next Topic: [PATCH] Make access to task's nsproxy liter
Goto Forum:
  


Current Time: Sun Nov 17 09:16:42 GMT 2024

Total time taken to generate the page: 0.02935 seconds