[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20070716135028.GA2040@APFDCB5C>
Date: Mon, 16 Jul 2007 22:50:28 +0900
From: Akinobu Mita <akinobu.mita@...il.com>
To: linux-kernel@...r.kernel.org, Greg Kroah-Hartman <gregkh@...e.de>
Subject: [PATCH 1/10] sysfs: fix kmem_cache_free(NULL)
This patch fixes out of memory error handling in sysfs_new_dirent().
kmem_cache_free() with NULL is not allowed.
Cc: Greg Kroah-Hartman <gregkh@...e.de>
Signed-off-by: Akinobu Mita <akinobu.mita@...il.com>
---
fs/sysfs/dir.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
Index: 2.6-mm/fs/sysfs/dir.c
===================================================================
--- 2.6-mm.orig/fs/sysfs/dir.c
+++ 2.6-mm/fs/sysfs/dir.c
@@ -361,20 +361,20 @@ static struct dentry_operations sysfs_de
struct sysfs_dirent *sysfs_new_dirent(const char *name, umode_t mode, int type)
{
char *dup_name = NULL;
- struct sysfs_dirent *sd = NULL;
+ struct sysfs_dirent *sd;
if (type & SYSFS_COPY_NAME) {
name = dup_name = kstrdup(name, GFP_KERNEL);
if (!name)
- goto err_out;
+ return NULL;
}
sd = kmem_cache_zalloc(sysfs_dir_cachep, GFP_KERNEL);
if (!sd)
- goto err_out;
+ goto err_out1;
if (sysfs_alloc_ino(&sd->s_ino))
- goto err_out;
+ goto err_out2;
atomic_set(&sd->s_count, 1);
atomic_set(&sd->s_active, 0);
@@ -386,9 +386,10 @@ struct sysfs_dirent *sysfs_new_dirent(co
return sd;
- err_out:
- kfree(dup_name);
+ err_out2:
kmem_cache_free(sysfs_dir_cachep, sd);
+ err_out1:
+ kfree(dup_name);
return NULL;
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists