From c9f4f0d82bc76de06fc2a9b2f536814487079744 Mon Sep 17 00:00:00 2001
From: fanyong <fanyong>
Date: Thu, 30 Aug 2007 05:06:18 +0000
Subject: [PATCH] Check "sbi->s_mb_history" before using it.

b=12876
i=adilger
i=huanghua
---
 ldiskfs/kernel_patches/patches/ext3-mballoc2-2.6-fc5.patch | 7 ++++---
 .../kernel_patches/patches/ext3-mballoc2-2.6.9-rhel4.patch | 7 ++++---
 ldiskfs/kernel_patches/patches/ext3-mballoc3-core.patch    | 7 ++++---
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/ldiskfs/kernel_patches/patches/ext3-mballoc2-2.6-fc5.patch b/ldiskfs/kernel_patches/patches/ext3-mballoc2-2.6-fc5.patch
index 1964a6a756..11b7482cdf 100644
--- a/ldiskfs/kernel_patches/patches/ext3-mballoc2-2.6-fc5.patch
+++ b/ldiskfs/kernel_patches/patches/ext3-mballoc2-2.6-fc5.patch
@@ -362,7 +362,7 @@ Index: linux-2.6.16.i686/fs/ext3/mballoc.c
 ===================================================================
 --- linux-2.6.16.i686.orig/fs/ext3/mballoc.c	2006-05-31 04:14:15.752410384 +0800
 +++ linux-2.6.16.i686/fs/ext3/mballoc.c	2006-05-30 23:03:38.000000000 +0800
-@@ -0,0 +1,2725 @@
+@@ -0,0 +1,2726 @@
 +/*
 + * Copyright (c) 2003-2005, Cluster File Systems, Inc, info@clusterfs.com
 + * Written by Alex Tomas <alex@clusterfs.com>
@@ -2243,7 +2243,8 @@ Index: linux-2.6.16.i686/fs/ext3/mballoc.c
 +	spin_lock_init(&sbi->s_mb_history_lock);
 +	i = sbi->s_mb_history_max * sizeof(struct ext3_mb_history);
 +	sbi->s_mb_history = kmalloc(i, GFP_KERNEL);
-+	memset(sbi->s_mb_history, 0, i);
++       if (likely(sbi->s_mb_history != NULL))
++               memset(sbi->s_mb_history, 0, i);
 +	/* if we can't allocate history, then we simple won't use it */
 +}
 +
@@ -2254,7 +2255,7 @@ Index: linux-2.6.16.i686/fs/ext3/mballoc.c
 +	struct ext3_sb_info *sbi = EXT3_SB(sb);
 +	struct ext3_mb_history h;
 +
-+	if (likely(sbi->s_mb_history == NULL))
++	if (unlikely(sbi->s_mb_history == NULL))
 +		return;
 +
 +	h.pid = current->pid;
diff --git a/ldiskfs/kernel_patches/patches/ext3-mballoc2-2.6.9-rhel4.patch b/ldiskfs/kernel_patches/patches/ext3-mballoc2-2.6.9-rhel4.patch
index f80b66e83e..73803474cd 100644
--- a/ldiskfs/kernel_patches/patches/ext3-mballoc2-2.6.9-rhel4.patch
+++ b/ldiskfs/kernel_patches/patches/ext3-mballoc2-2.6.9-rhel4.patch
@@ -380,7 +380,7 @@ Index: linux-2.6.9-full/fs/ext3/mballoc.c
 ===================================================================
 --- linux-2.6.9-full.orig/fs/ext3/mballoc.c	2006-10-23 18:07:54.821533176 +0400
 +++ linux-2.6.9-full/fs/ext3/mballoc.c	2006-10-24 13:00:56.000000000 +0400
-@@ -0,0 +1,2725 @@
+@@ -0,0 +1,2726 @@
 +/*
 + * Copyright (c) 2003-2005, Cluster File Systems, Inc, info@clusterfs.com
 + * Written by Alex Tomas <alex@clusterfs.com>
@@ -2261,7 +2261,8 @@ Index: linux-2.6.9-full/fs/ext3/mballoc.c
 +	spin_lock_init(&sbi->s_mb_history_lock);
 +	i = sbi->s_mb_history_max * sizeof(struct ext3_mb_history);
 +	sbi->s_mb_history = kmalloc(i, GFP_KERNEL);
-+	memset(sbi->s_mb_history, 0, i);
++       if (likely(sbi->s_mb_history != NULL))
++               memset(sbi->s_mb_history, 0, i);
 +	/* if we can't allocate history, then we simple won't use it */
 +}
 +
@@ -2272,7 +2273,7 @@ Index: linux-2.6.9-full/fs/ext3/mballoc.c
 +	struct ext3_sb_info *sbi = EXT3_SB(sb);
 +	struct ext3_mb_history h;
 +
-+	if (likely(sbi->s_mb_history == NULL))
++	if (unlikely(sbi->s_mb_history == NULL))
 +		return;
 +
 +	h.pid = current->pid;
diff --git a/ldiskfs/kernel_patches/patches/ext3-mballoc3-core.patch b/ldiskfs/kernel_patches/patches/ext3-mballoc3-core.patch
index 378d37f8f1..9f8f7e356a 100644
--- a/ldiskfs/kernel_patches/patches/ext3-mballoc3-core.patch
+++ b/ldiskfs/kernel_patches/patches/ext3-mballoc3-core.patch
@@ -183,7 +183,7 @@ Index: linux-2.6.9-full/fs/ext3/mballoc.c
 ===================================================================
 --- linux-2.6.9-full.orig/fs/ext3/mballoc.c	2007-07-14 04:24:39.138985848 +0400
 +++ linux-2.6.9-full/fs/ext3/mballoc.c	2007-07-20 11:31:03.000000000 +0400
-@@ -0,0 +1,4391 @@
+@@ -0,0 +1,4392 @@
 +/*
 + * Copyright (c) 2003-2006, Cluster File Systems, Inc, info@clusterfs.com
 + * Written by Alex Tomas <alex@clusterfs.com>
@@ -2388,7 +2388,8 @@ Index: linux-2.6.9-full/fs/ext3/mballoc.c
 +	spin_lock_init(&sbi->s_mb_history_lock);
 +	i = sbi->s_mb_history_max * sizeof(struct ext3_mb_history);
 +	sbi->s_mb_history = kmalloc(i, GFP_KERNEL);
-+	memset(sbi->s_mb_history, 0, i);
++       if (likely(sbi->s_mb_history != NULL))
++               memset(sbi->s_mb_history, 0, i);
 +	/* if we can't allocate history, then we simple won't use it */
 +}
 +
@@ -2398,7 +2399,7 @@ Index: linux-2.6.9-full/fs/ext3/mballoc.c
 +	struct ext3_sb_info *sbi = EXT3_SB(ac->ac_sb);
 +	struct ext3_mb_history h;
 +
-+	if (likely(sbi->s_mb_history == NULL))
++	if (unlikely(sbi->s_mb_history == NULL))
 +		return;
 +
 +	if (!(ac->ac_op & sbi->s_mb_history_filter))
-- 
GitLab