aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Neukum <neukum@fachschaft.cup.uni-muenchen.de>2006-03-25 06:08:13 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-25 11:23:00 -0500
commit11b0b5abb2097a63c1081d9b7e825b987b227972 (patch)
tree162c828c8d807a1b30869acbe11682dc9222dc16
parent656bde5728b824ca23fcab8bc5800b309ea48d64 (diff)
[PATCH] use kzalloc and kcalloc in core fs code
Signed-off-by: Oliver Neukum <oliver@neukum.name> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--fs/aio.c3
-rw-r--r--fs/binfmt_elf.c3
-rw-r--r--fs/bio.c7
-rw-r--r--fs/char_dev.c7
-rw-r--r--fs/compat.c3
-rw-r--r--fs/exec.c3
-rw-r--r--fs/pipe.c3
-rw-r--r--fs/super.c3
8 files changed, 10 insertions, 22 deletions
diff --git a/fs/aio.c b/fs/aio.c
index aec2b1916d1b..e41e932ba489 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -122,10 +122,9 @@ static int aio_setup_ring(struct kioctx *ctx)
122 info->nr = 0; 122 info->nr = 0;
123 info->ring_pages = info->internal_pages; 123 info->ring_pages = info->internal_pages;
124 if (nr_pages > AIO_RING_PAGES) { 124 if (nr_pages > AIO_RING_PAGES) {
125 info->ring_pages = kmalloc(sizeof(struct page *) * nr_pages, GFP_KERNEL); 125 info->ring_pages = kcalloc(nr_pages, sizeof(struct page *), GFP_KERNEL);
126 if (!info->ring_pages) 126 if (!info->ring_pages)
127 return -ENOMEM; 127 return -ENOMEM;
128 memset(info->ring_pages, 0, sizeof(struct page *) * nr_pages);
129 } 128 }
130 129
131 info->mmap_size = nr_pages * PAGE_SIZE; 130 info->mmap_size = nr_pages * PAGE_SIZE;
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index c2eac2a50bd2..61c21e7dc95d 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1465,12 +1465,11 @@ static int elf_core_dump(long signr, struct pt_regs * regs, struct file * file)
1465 read_lock(&tasklist_lock); 1465 read_lock(&tasklist_lock);
1466 do_each_thread(g,p) 1466 do_each_thread(g,p)
1467 if (current->mm == p->mm && current != p) { 1467 if (current->mm == p->mm && current != p) {
1468 tmp = kmalloc(sizeof(*tmp), GFP_ATOMIC); 1468 tmp = kzalloc(sizeof(*tmp), GFP_ATOMIC);
1469 if (!tmp) { 1469 if (!tmp) {
1470 read_unlock(&tasklist_lock); 1470 read_unlock(&tasklist_lock);
1471 goto cleanup; 1471 goto cleanup;
1472 } 1472 }
1473 memset(tmp, 0, sizeof(*tmp));
1474 INIT_LIST_HEAD(&tmp->list); 1473 INIT_LIST_HEAD(&tmp->list);
1475 tmp->thread = p; 1474 tmp->thread = p;
1476 list_add(&tmp->list, &thread_list); 1475 list_add(&tmp->list, &thread_list);
diff --git a/fs/bio.c b/fs/bio.c
index 0a8c59cb68f5..73e664c01d30 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -636,12 +636,10 @@ static struct bio *__bio_map_user_iov(request_queue_t *q,
636 return ERR_PTR(-ENOMEM); 636 return ERR_PTR(-ENOMEM);
637 637
638 ret = -ENOMEM; 638 ret = -ENOMEM;
639 pages = kmalloc(nr_pages * sizeof(struct page *), GFP_KERNEL); 639 pages = kcalloc(nr_pages, sizeof(struct page *), GFP_KERNEL);
640 if (!pages) 640 if (!pages)
641 goto out; 641 goto out;
642 642
643 memset(pages, 0, nr_pages * sizeof(struct page *));
644
645 for (i = 0; i < iov_count; i++) { 643 for (i = 0; i < iov_count; i++) {
646 unsigned long uaddr = (unsigned long)iov[i].iov_base; 644 unsigned long uaddr = (unsigned long)iov[i].iov_base;
647 unsigned long len = iov[i].iov_len; 645 unsigned long len = iov[i].iov_len;
@@ -1186,12 +1184,11 @@ void bioset_free(struct bio_set *bs)
1186 1184
1187struct bio_set *bioset_create(int bio_pool_size, int bvec_pool_size, int scale) 1185struct bio_set *bioset_create(int bio_pool_size, int bvec_pool_size, int scale)
1188{ 1186{
1189 struct bio_set *bs = kmalloc(sizeof(*bs), GFP_KERNEL); 1187 struct bio_set *bs = kzalloc(sizeof(*bs), GFP_KERNEL);
1190 1188
1191 if (!bs) 1189 if (!bs)
1192 return NULL; 1190 return NULL;
1193 1191
1194 memset(bs, 0, sizeof(*bs));
1195 bs->bio_pool = mempool_create(bio_pool_size, mempool_alloc_slab, 1192 bs->bio_pool = mempool_create(bio_pool_size, mempool_alloc_slab,
1196 mempool_free_slab, bio_slab); 1193 mempool_free_slab, bio_slab);
1197 1194
diff --git a/fs/char_dev.c b/fs/char_dev.c
index 5c36345c9bf7..8c6eb04d31e2 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -146,12 +146,10 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor,
146 int ret = 0; 146 int ret = 0;
147 int i; 147 int i;
148 148
149 cd = kmalloc(sizeof(struct char_device_struct), GFP_KERNEL); 149 cd = kzalloc(sizeof(struct char_device_struct), GFP_KERNEL);
150 if (cd == NULL) 150 if (cd == NULL)
151 return ERR_PTR(-ENOMEM); 151 return ERR_PTR(-ENOMEM);
152 152
153 memset(cd, 0, sizeof(struct char_device_struct));
154
155 mutex_lock(&chrdevs_lock); 153 mutex_lock(&chrdevs_lock);
156 154
157 /* temporary */ 155 /* temporary */
@@ -466,9 +464,8 @@ static struct kobj_type ktype_cdev_dynamic = {
466 464
467struct cdev *cdev_alloc(void) 465struct cdev *cdev_alloc(void)
468{ 466{
469 struct cdev *p = kmalloc(sizeof(struct cdev), GFP_KERNEL); 467 struct cdev *p = kzalloc(sizeof(struct cdev), GFP_KERNEL);
470 if (p) { 468 if (p) {
471 memset(p, 0, sizeof(struct cdev));
472 p->kobj.ktype = &ktype_cdev_dynamic; 469 p->kobj.ktype = &ktype_cdev_dynamic;
473 INIT_LIST_HEAD(&p->list); 470 INIT_LIST_HEAD(&p->list);
474 kobject_init(&p->kobj); 471 kobject_init(&p->kobj);
diff --git a/fs/compat.c b/fs/compat.c
index 263990ae4096..ef5a0771592d 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -1476,10 +1476,9 @@ int compat_do_execve(char * filename,
1476 int i; 1476 int i;
1477 1477
1478 retval = -ENOMEM; 1478 retval = -ENOMEM;
1479 bprm = kmalloc(sizeof(*bprm), GFP_KERNEL); 1479 bprm = kzalloc(sizeof(*bprm), GFP_KERNEL);
1480 if (!bprm) 1480 if (!bprm)
1481 goto out_ret; 1481 goto out_ret;
1482 memset(bprm, 0, sizeof(*bprm));
1483 1482
1484 file = open_exec(filename); 1483 file = open_exec(filename);
1485 retval = PTR_ERR(file); 1484 retval = PTR_ERR(file);
diff --git a/fs/exec.c b/fs/exec.c
index d8c477a56257..995cba3c62b8 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1143,10 +1143,9 @@ int do_execve(char * filename,
1143 int i; 1143 int i;
1144 1144
1145 retval = -ENOMEM; 1145 retval = -ENOMEM;
1146 bprm = kmalloc(sizeof(*bprm), GFP_KERNEL); 1146 bprm = kzalloc(sizeof(*bprm), GFP_KERNEL);
1147 if (!bprm) 1147 if (!bprm)
1148 goto out_ret; 1148 goto out_ret;
1149 memset(bprm, 0, sizeof(*bprm));
1150 1149
1151 file = open_exec(filename); 1150 file = open_exec(filename);
1152 retval = PTR_ERR(file); 1151 retval = PTR_ERR(file);
diff --git a/fs/pipe.c b/fs/pipe.c
index 8aada8e426f4..d976866a115b 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -662,10 +662,9 @@ struct inode* pipe_new(struct inode* inode)
662{ 662{
663 struct pipe_inode_info *info; 663 struct pipe_inode_info *info;
664 664
665 info = kmalloc(sizeof(struct pipe_inode_info), GFP_KERNEL); 665 info = kzalloc(sizeof(struct pipe_inode_info), GFP_KERNEL);
666 if (!info) 666 if (!info)
667 goto fail_page; 667 goto fail_page;
668 memset(info, 0, sizeof(*info));
669 inode->i_pipe = info; 668 inode->i_pipe = info;
670 669
671 init_waitqueue_head(PIPE_WAIT(*inode)); 670 init_waitqueue_head(PIPE_WAIT(*inode));
diff --git a/fs/super.c b/fs/super.c
index 37554b876182..8743e9bbb297 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -55,11 +55,10 @@ DEFINE_SPINLOCK(sb_lock);
55 */ 55 */
56static struct super_block *alloc_super(void) 56static struct super_block *alloc_super(void)
57{ 57{
58 struct super_block *s = kmalloc(sizeof(struct super_block), GFP_USER); 58 struct super_block *s = kzalloc(sizeof(struct super_block), GFP_USER);
59 static struct super_operations default_op; 59 static struct super_operations default_op;
60 60
61 if (s) { 61 if (s) {
62 memset(s, 0, sizeof(struct super_block));
63 if (security_sb_alloc(s)) { 62 if (security_sb_alloc(s)) {
64 kfree(s); 63 kfree(s);
65 s = NULL; 64 s = NULL;