From: Roel Kluin <12o3l@tiscali.nl>
To: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Cc: alex@clusterfs.com, sct@redhat.com, akpm@linux-foundation.org,
adilger@clusterfs.com, linux-ext4@vger.kernel.org,
lkml <linux-kernel@vger.kernel.org>
Subject: [PATCH v2] mballoc: fix hot spins after err_freebuddy and err_freemeta
Date: Thu, 17 Apr 2008 20:29:18 +0200 [thread overview]
Message-ID: <480796FE.2010707@tiscali.nl> (raw)
In-Reply-To: <20080417175843.GA7517@skywalker>
Aneesh Kumar K.V wrote:
> The function needs more changes. For ex:
>
> 2279 if (meta_group_info[j] == NULL) {
> 2280 printk(KERN_ERR "EXT4-fs: can't allocate buddy mem\n");
> 2281 i--;
> 2282 goto err_freebuddy;
> 2283 }
>
> That decrement i--; could result in bad value if i == 0;.
Thanks Aneesh,
---
Signed-off-by: Roel Kluin <12o3l@tiscali.nl>
ext4_mb_init_backend() has a variable i of type ext4_group_t. which is typedefined
in include/linux/ext4_fs_i.h:34 to unsigned long. Since unsigned, i >= 0 is always
true, so fix hot spins after err_freebuddy and err_freemeta.
Also when meta_group_info cannot be allocated prevent a decrement of i when zero.
Signed-off-by: Roel Kluin <12o3l@tiscali.nl>
---
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index ef97f19..2c13dca 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2572,8 +2572,13 @@ static int ext4_mb_init_backend(struct super_block *sb)
meta_group_info[j] = kzalloc(len, GFP_KERNEL);
if (meta_group_info[j] == NULL) {
printk(KERN_ERR "EXT4-fs: can't allocate buddy mem\n");
- i--;
- goto err_freebuddy;
+ if (i != 0) {
+ i--;
+ goto err_freebuddy;
+ } else {
+ i = num_meta_group_infos - 1;
+ goto err_freemeta;
+ }
}
desc = ext4_get_group_desc(sb, i, NULL);
if (desc == NULL) {
@@ -2618,14 +2623,14 @@ static int ext4_mb_init_backend(struct super_block *sb)
return 0;
err_freebuddy:
- while (i >= 0) {
+ do {
kfree(ext4_get_group_info(sb, i));
- i--;
- }
- i = num_meta_group_infos;
+ } while (i-- != 0);
+ i = num_meta_group_infos - 1;
err_freemeta:
- while (--i >= 0)
+ do {
kfree(sbi->s_group_info[i]);
+ } while (i-- != 0);
iput(sbi->s_buddy_cache);
err_freesgi:
kfree(sbi->s_group_info);
next prev parent reply other threads:[~2008-04-17 18:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-17 16:09 [PATCH] mballoc: fix hot spins after err_freebuddy and err_freemeta Roel Kluin
2008-04-17 17:58 ` Aneesh Kumar K.V
2008-04-17 18:29 ` Roel Kluin [this message]
2008-04-18 5:14 ` [PATCH v2] " Aneesh Kumar K.V
2008-04-18 5:21 ` Aneesh Kumar K.V
2008-04-18 12:13 ` Roel Kluin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=480796FE.2010707@tiscali.nl \
--to=12o3l@tiscali.nl \
--cc=adilger@clusterfs.com \
--cc=akpm@linux-foundation.org \
--cc=alex@clusterfs.com \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sct@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.