diff options
author | Robert P. J. Day <rpjday@mindspring.com> | 2007-02-10 04:45:03 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-02-11 13:51:27 -0500 |
commit | c376222960ae91d5ffb9197ee36771aaed1d9f90 (patch) | |
tree | 7f431c42529fec77433d33490bd9f2a8c47ba091 /fs | |
parent | 1b135431abf5ea92e61bf4e91d93726c7b96da5f (diff) |
[PATCH] Transform kmem_cache_alloc()+memset(0) -> kmem_cache_zalloc().
Replace appropriate pairs of "kmem_cache_alloc()" + "memset(0)" with the
corresponding "kmem_cache_zalloc()" call.
Signed-off-by: Robert P. J. Day <rpjday@mindspring.com>
Cc: "Luck, Tony" <tony.luck@intel.com>
Cc: Andi Kleen <ak@muc.de>
Cc: Roland McGrath <roland@redhat.com>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Cc: Greg KH <greg@kroah.com>
Acked-by: Joel Becker <Joel.Becker@oracle.com>
Cc: Steven Whitehouse <swhiteho@redhat.com>
Cc: Jan Kara <jack@ucw.cz>
Cc: Michael Halcrow <mhalcrow@us.ibm.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Cc: James Morris <jmorris@namei.org>
Cc: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/aio.c | 3 | ||||
-rw-r--r-- | fs/configfs/dir.c | 3 | ||||
-rw-r--r-- | fs/dlm/memory.c | 4 | ||||
-rw-r--r-- | fs/dquot.c | 3 | ||||
-rw-r--r-- | fs/ecryptfs/crypto.c | 4 | ||||
-rw-r--r-- | fs/ecryptfs/file.c | 3 | ||||
-rw-r--r-- | fs/ecryptfs/inode.c | 5 | ||||
-rw-r--r-- | fs/ecryptfs/keystore.c | 4 | ||||
-rw-r--r-- | fs/ecryptfs/main.c | 8 | ||||
-rw-r--r-- | fs/exec.c | 4 | ||||
-rw-r--r-- | fs/gfs2/meta_io.c | 3 | ||||
-rw-r--r-- | fs/namespace.c | 3 | ||||
-rw-r--r-- | fs/smbfs/request.c | 3 | ||||
-rw-r--r-- | fs/sysfs/dir.c | 3 |
14 files changed, 17 insertions, 36 deletions
@@ -211,11 +211,10 @@ static struct kioctx *ioctx_alloc(unsigned nr_events) | |||
211 | if ((unsigned long)nr_events > aio_max_nr) | 211 | if ((unsigned long)nr_events > aio_max_nr) |
212 | return ERR_PTR(-EAGAIN); | 212 | return ERR_PTR(-EAGAIN); |
213 | 213 | ||
214 | ctx = kmem_cache_alloc(kioctx_cachep, GFP_KERNEL); | 214 | ctx = kmem_cache_zalloc(kioctx_cachep, GFP_KERNEL); |
215 | if (!ctx) | 215 | if (!ctx) |
216 | return ERR_PTR(-ENOMEM); | 216 | return ERR_PTR(-ENOMEM); |
217 | 217 | ||
218 | memset(ctx, 0, sizeof(*ctx)); | ||
219 | ctx->max_reqs = nr_events; | 218 | ctx->max_reqs = nr_events; |
220 | mm = ctx->mm = current->mm; | 219 | mm = ctx->mm = current->mm; |
221 | atomic_inc(&mm->mm_count); | 220 | atomic_inc(&mm->mm_count); |
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index 1814ba446809..9371ee209954 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c | |||
@@ -72,11 +72,10 @@ static struct configfs_dirent *configfs_new_dirent(struct configfs_dirent * pare | |||
72 | { | 72 | { |
73 | struct configfs_dirent * sd; | 73 | struct configfs_dirent * sd; |
74 | 74 | ||
75 | sd = kmem_cache_alloc(configfs_dir_cachep, GFP_KERNEL); | 75 | sd = kmem_cache_zalloc(configfs_dir_cachep, GFP_KERNEL); |
76 | if (!sd) | 76 | if (!sd) |
77 | return NULL; | 77 | return NULL; |
78 | 78 | ||
79 | memset(sd, 0, sizeof(*sd)); | ||
80 | atomic_set(&sd->s_count, 1); | 79 | atomic_set(&sd->s_count, 1); |
81 | INIT_LIST_HEAD(&sd->s_links); | 80 | INIT_LIST_HEAD(&sd->s_links); |
82 | INIT_LIST_HEAD(&sd->s_children); | 81 | INIT_LIST_HEAD(&sd->s_children); |
diff --git a/fs/dlm/memory.c b/fs/dlm/memory.c index 5352b03ff5aa..f858fef6e41c 100644 --- a/fs/dlm/memory.c +++ b/fs/dlm/memory.c | |||
@@ -76,9 +76,7 @@ struct dlm_lkb *allocate_lkb(struct dlm_ls *ls) | |||
76 | { | 76 | { |
77 | struct dlm_lkb *lkb; | 77 | struct dlm_lkb *lkb; |
78 | 78 | ||
79 | lkb = kmem_cache_alloc(lkb_cache, GFP_KERNEL); | 79 | lkb = kmem_cache_zalloc(lkb_cache, GFP_KERNEL); |
80 | if (lkb) | ||
81 | memset(lkb, 0, sizeof(*lkb)); | ||
82 | return lkb; | 80 | return lkb; |
83 | } | 81 | } |
84 | 82 | ||
diff --git a/fs/dquot.c b/fs/dquot.c index 0952cc474d9a..a561fb29e203 100644 --- a/fs/dquot.c +++ b/fs/dquot.c | |||
@@ -600,11 +600,10 @@ static struct dquot *get_empty_dquot(struct super_block *sb, int type) | |||
600 | { | 600 | { |
601 | struct dquot *dquot; | 601 | struct dquot *dquot; |
602 | 602 | ||
603 | dquot = kmem_cache_alloc(dquot_cachep, GFP_NOFS); | 603 | dquot = kmem_cache_zalloc(dquot_cachep, GFP_NOFS); |
604 | if(!dquot) | 604 | if(!dquot) |
605 | return NODQUOT; | 605 | return NODQUOT; |
606 | 606 | ||
607 | memset((caddr_t)dquot, 0, sizeof(struct dquot)); | ||
608 | mutex_init(&dquot->dq_lock); | 607 | mutex_init(&dquot->dq_lock); |
609 | INIT_LIST_HEAD(&dquot->dq_free); | 608 | INIT_LIST_HEAD(&dquot->dq_free); |
610 | INIT_LIST_HEAD(&dquot->dq_inuse); | 609 | INIT_LIST_HEAD(&dquot->dq_inuse); |
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c index a86a55ccf874..75bbfae55081 100644 --- a/fs/ecryptfs/crypto.c +++ b/fs/ecryptfs/crypto.c | |||
@@ -1332,13 +1332,13 @@ int ecryptfs_write_headers(struct dentry *ecryptfs_dentry, | |||
1332 | goto out; | 1332 | goto out; |
1333 | } | 1333 | } |
1334 | /* Released in this function */ | 1334 | /* Released in this function */ |
1335 | page_virt = kmem_cache_alloc(ecryptfs_header_cache_0, GFP_USER); | 1335 | page_virt = kmem_cache_zalloc(ecryptfs_header_cache_0, GFP_USER); |
1336 | if (!page_virt) { | 1336 | if (!page_virt) { |
1337 | ecryptfs_printk(KERN_ERR, "Out of memory\n"); | 1337 | ecryptfs_printk(KERN_ERR, "Out of memory\n"); |
1338 | rc = -ENOMEM; | 1338 | rc = -ENOMEM; |
1339 | goto out; | 1339 | goto out; |
1340 | } | 1340 | } |
1341 | memset(page_virt, 0, PAGE_CACHE_SIZE); | 1341 | |
1342 | rc = ecryptfs_write_headers_virt(page_virt, crypt_stat, | 1342 | rc = ecryptfs_write_headers_virt(page_virt, crypt_stat, |
1343 | ecryptfs_dentry); | 1343 | ecryptfs_dentry); |
1344 | if (unlikely(rc)) { | 1344 | if (unlikely(rc)) { |
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c index c5a2e5298f15..779c3477d93c 100644 --- a/fs/ecryptfs/file.c +++ b/fs/ecryptfs/file.c | |||
@@ -251,7 +251,7 @@ static int ecryptfs_open(struct inode *inode, struct file *file) | |||
251 | int lower_flags; | 251 | int lower_flags; |
252 | 252 | ||
253 | /* Released in ecryptfs_release or end of function if failure */ | 253 | /* Released in ecryptfs_release or end of function if failure */ |
254 | file_info = kmem_cache_alloc(ecryptfs_file_info_cache, GFP_KERNEL); | 254 | file_info = kmem_cache_zalloc(ecryptfs_file_info_cache, GFP_KERNEL); |
255 | ecryptfs_set_file_private(file, file_info); | 255 | ecryptfs_set_file_private(file, file_info); |
256 | if (!file_info) { | 256 | if (!file_info) { |
257 | ecryptfs_printk(KERN_ERR, | 257 | ecryptfs_printk(KERN_ERR, |
@@ -259,7 +259,6 @@ static int ecryptfs_open(struct inode *inode, struct file *file) | |||
259 | rc = -ENOMEM; | 259 | rc = -ENOMEM; |
260 | goto out; | 260 | goto out; |
261 | } | 261 | } |
262 | memset(file_info, 0, sizeof(*file_info)); | ||
263 | lower_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry); | 262 | lower_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry); |
264 | crypt_stat = &ecryptfs_inode_to_private(inode)->crypt_stat; | 263 | crypt_stat = &ecryptfs_inode_to_private(inode)->crypt_stat; |
265 | mount_crypt_stat = &ecryptfs_superblock_to_private( | 264 | mount_crypt_stat = &ecryptfs_superblock_to_private( |
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index 11f5e5076aef..d4f02f3e18d7 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c | |||
@@ -361,8 +361,7 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry, | |||
361 | goto out; | 361 | goto out; |
362 | } | 362 | } |
363 | /* Released in this function */ | 363 | /* Released in this function */ |
364 | page_virt = | 364 | page_virt = kmem_cache_zalloc(ecryptfs_header_cache_2, |
365 | (char *)kmem_cache_alloc(ecryptfs_header_cache_2, | ||
366 | GFP_USER); | 365 | GFP_USER); |
367 | if (!page_virt) { | 366 | if (!page_virt) { |
368 | rc = -ENOMEM; | 367 | rc = -ENOMEM; |
@@ -370,7 +369,7 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry, | |||
370 | "Cannot ecryptfs_kmalloc a page\n"); | 369 | "Cannot ecryptfs_kmalloc a page\n"); |
371 | goto out_dput; | 370 | goto out_dput; |
372 | } | 371 | } |
373 | memset(page_virt, 0, PAGE_CACHE_SIZE); | 372 | |
374 | rc = ecryptfs_read_header_region(page_virt, lower_dentry, nd->mnt); | 373 | rc = ecryptfs_read_header_region(page_virt, lower_dentry, nd->mnt); |
375 | crypt_stat = &ecryptfs_inode_to_private(dentry->d_inode)->crypt_stat; | 374 | crypt_stat = &ecryptfs_inode_to_private(dentry->d_inode)->crypt_stat; |
376 | if (!ECRYPTFS_CHECK_FLAG(crypt_stat->flags, ECRYPTFS_POLICY_APPLIED)) | 375 | if (!ECRYPTFS_CHECK_FLAG(crypt_stat->flags, ECRYPTFS_POLICY_APPLIED)) |
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c index 745c0f1bfbbd..80bccd5ff8e6 100644 --- a/fs/ecryptfs/keystore.c +++ b/fs/ecryptfs/keystore.c | |||
@@ -207,14 +207,12 @@ parse_tag_3_packet(struct ecryptfs_crypt_stat *crypt_stat, | |||
207 | /* Released: wipe_auth_tok_list called in ecryptfs_parse_packet_set or | 207 | /* Released: wipe_auth_tok_list called in ecryptfs_parse_packet_set or |
208 | * at end of function upon failure */ | 208 | * at end of function upon failure */ |
209 | auth_tok_list_item = | 209 | auth_tok_list_item = |
210 | kmem_cache_alloc(ecryptfs_auth_tok_list_item_cache, GFP_KERNEL); | 210 | kmem_cache_zalloc(ecryptfs_auth_tok_list_item_cache, GFP_KERNEL); |
211 | if (!auth_tok_list_item) { | 211 | if (!auth_tok_list_item) { |
212 | ecryptfs_printk(KERN_ERR, "Unable to allocate memory\n"); | 212 | ecryptfs_printk(KERN_ERR, "Unable to allocate memory\n"); |
213 | rc = -ENOMEM; | 213 | rc = -ENOMEM; |
214 | goto out; | 214 | goto out; |
215 | } | 215 | } |
216 | memset(auth_tok_list_item, 0, | ||
217 | sizeof(struct ecryptfs_auth_tok_list_item)); | ||
218 | (*new_auth_tok) = &auth_tok_list_item->auth_tok; | 216 | (*new_auth_tok) = &auth_tok_list_item->auth_tok; |
219 | 217 | ||
220 | /* check for body size - one to two bytes */ | 218 | /* check for body size - one to two bytes */ |
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c index d0541ae8faba..fe41ab1566ee 100644 --- a/fs/ecryptfs/main.c +++ b/fs/ecryptfs/main.c | |||
@@ -378,15 +378,13 @@ ecryptfs_fill_super(struct super_block *sb, void *raw_data, int silent) | |||
378 | 378 | ||
379 | /* Released in ecryptfs_put_super() */ | 379 | /* Released in ecryptfs_put_super() */ |
380 | ecryptfs_set_superblock_private(sb, | 380 | ecryptfs_set_superblock_private(sb, |
381 | kmem_cache_alloc(ecryptfs_sb_info_cache, | 381 | kmem_cache_zalloc(ecryptfs_sb_info_cache, |
382 | GFP_KERNEL)); | 382 | GFP_KERNEL)); |
383 | if (!ecryptfs_superblock_to_private(sb)) { | 383 | if (!ecryptfs_superblock_to_private(sb)) { |
384 | ecryptfs_printk(KERN_WARNING, "Out of memory\n"); | 384 | ecryptfs_printk(KERN_WARNING, "Out of memory\n"); |
385 | rc = -ENOMEM; | 385 | rc = -ENOMEM; |
386 | goto out; | 386 | goto out; |
387 | } | 387 | } |
388 | memset(ecryptfs_superblock_to_private(sb), 0, | ||
389 | sizeof(struct ecryptfs_sb_info)); | ||
390 | sb->s_op = &ecryptfs_sops; | 388 | sb->s_op = &ecryptfs_sops; |
391 | /* Released through deactivate_super(sb) from get_sb_nodev */ | 389 | /* Released through deactivate_super(sb) from get_sb_nodev */ |
392 | sb->s_root = d_alloc(NULL, &(const struct qstr) { | 390 | sb->s_root = d_alloc(NULL, &(const struct qstr) { |
@@ -402,7 +400,7 @@ ecryptfs_fill_super(struct super_block *sb, void *raw_data, int silent) | |||
402 | /* Released in d_release when dput(sb->s_root) is called */ | 400 | /* Released in d_release when dput(sb->s_root) is called */ |
403 | /* through deactivate_super(sb) from get_sb_nodev() */ | 401 | /* through deactivate_super(sb) from get_sb_nodev() */ |
404 | ecryptfs_set_dentry_private(sb->s_root, | 402 | ecryptfs_set_dentry_private(sb->s_root, |
405 | kmem_cache_alloc(ecryptfs_dentry_info_cache, | 403 | kmem_cache_zalloc(ecryptfs_dentry_info_cache, |
406 | GFP_KERNEL)); | 404 | GFP_KERNEL)); |
407 | if (!ecryptfs_dentry_to_private(sb->s_root)) { | 405 | if (!ecryptfs_dentry_to_private(sb->s_root)) { |
408 | ecryptfs_printk(KERN_ERR, | 406 | ecryptfs_printk(KERN_ERR, |
@@ -410,8 +408,6 @@ ecryptfs_fill_super(struct super_block *sb, void *raw_data, int silent) | |||
410 | rc = -ENOMEM; | 408 | rc = -ENOMEM; |
411 | goto out; | 409 | goto out; |
412 | } | 410 | } |
413 | memset(ecryptfs_dentry_to_private(sb->s_root), 0, | ||
414 | sizeof(struct ecryptfs_dentry_info)); | ||
415 | rc = 0; | 411 | rc = 0; |
416 | out: | 412 | out: |
417 | /* Should be able to rely on deactivate_super called from | 413 | /* Should be able to rely on deactivate_super called from |
@@ -405,12 +405,10 @@ int setup_arg_pages(struct linux_binprm *bprm, | |||
405 | bprm->loader += stack_base; | 405 | bprm->loader += stack_base; |
406 | bprm->exec += stack_base; | 406 | bprm->exec += stack_base; |
407 | 407 | ||
408 | mpnt = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL); | 408 | mpnt = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL); |
409 | if (!mpnt) | 409 | if (!mpnt) |
410 | return -ENOMEM; | 410 | return -ENOMEM; |
411 | 411 | ||
412 | memset(mpnt, 0, sizeof(*mpnt)); | ||
413 | |||
414 | down_write(&mm->mmap_sem); | 412 | down_write(&mm->mmap_sem); |
415 | { | 413 | { |
416 | mpnt->vm_mm = mm; | 414 | mpnt->vm_mm = mm; |
diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c index 0e34d9918973..e62d4f620c58 100644 --- a/fs/gfs2/meta_io.c +++ b/fs/gfs2/meta_io.c | |||
@@ -282,8 +282,7 @@ void gfs2_attach_bufdata(struct gfs2_glock *gl, struct buffer_head *bh, | |||
282 | return; | 282 | return; |
283 | } | 283 | } |
284 | 284 | ||
285 | bd = kmem_cache_alloc(gfs2_bufdata_cachep, GFP_NOFS | __GFP_NOFAIL), | 285 | bd = kmem_cache_zalloc(gfs2_bufdata_cachep, GFP_NOFS | __GFP_NOFAIL), |
286 | memset(bd, 0, sizeof(struct gfs2_bufdata)); | ||
287 | bd->bd_bh = bh; | 286 | bd->bd_bh = bh; |
288 | bd->bd_gl = gl; | 287 | bd->bd_gl = gl; |
289 | 288 | ||
diff --git a/fs/namespace.c b/fs/namespace.c index 5ef336c1103c..fd999cab7b57 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -53,9 +53,8 @@ static inline unsigned long hash(struct vfsmount *mnt, struct dentry *dentry) | |||
53 | 53 | ||
54 | struct vfsmount *alloc_vfsmnt(const char *name) | 54 | struct vfsmount *alloc_vfsmnt(const char *name) |
55 | { | 55 | { |
56 | struct vfsmount *mnt = kmem_cache_alloc(mnt_cache, GFP_KERNEL); | 56 | struct vfsmount *mnt = kmem_cache_zalloc(mnt_cache, GFP_KERNEL); |
57 | if (mnt) { | 57 | if (mnt) { |
58 | memset(mnt, 0, sizeof(struct vfsmount)); | ||
59 | atomic_set(&mnt->mnt_count, 1); | 58 | atomic_set(&mnt->mnt_count, 1); |
60 | INIT_LIST_HEAD(&mnt->mnt_hash); | 59 | INIT_LIST_HEAD(&mnt->mnt_hash); |
61 | INIT_LIST_HEAD(&mnt->mnt_child); | 60 | INIT_LIST_HEAD(&mnt->mnt_child); |
diff --git a/fs/smbfs/request.c b/fs/smbfs/request.c index a4bcae8a9aff..42261dbdf60f 100644 --- a/fs/smbfs/request.c +++ b/fs/smbfs/request.c | |||
@@ -61,7 +61,7 @@ static struct smb_request *smb_do_alloc_request(struct smb_sb_info *server, | |||
61 | struct smb_request *req; | 61 | struct smb_request *req; |
62 | unsigned char *buf = NULL; | 62 | unsigned char *buf = NULL; |
63 | 63 | ||
64 | req = kmem_cache_alloc(req_cachep, GFP_KERNEL); | 64 | req = kmem_cache_zalloc(req_cachep, GFP_KERNEL); |
65 | VERBOSE("allocating request: %p\n", req); | 65 | VERBOSE("allocating request: %p\n", req); |
66 | if (!req) | 66 | if (!req) |
67 | goto out; | 67 | goto out; |
@@ -74,7 +74,6 @@ static struct smb_request *smb_do_alloc_request(struct smb_sb_info *server, | |||
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | memset(req, 0, sizeof(struct smb_request)); | ||
78 | req->rq_buffer = buf; | 77 | req->rq_buffer = buf; |
79 | req->rq_bufsize = bufsize; | 78 | req->rq_bufsize = bufsize; |
80 | req->rq_server = server; | 79 | req->rq_server = server; |
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index 9dcdf556c99c..9e95e7abaf69 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c | |||
@@ -37,11 +37,10 @@ static struct sysfs_dirent * __sysfs_new_dirent(void * element) | |||
37 | { | 37 | { |
38 | struct sysfs_dirent * sd; | 38 | struct sysfs_dirent * sd; |
39 | 39 | ||
40 | sd = kmem_cache_alloc(sysfs_dir_cachep, GFP_KERNEL); | 40 | sd = kmem_cache_zalloc(sysfs_dir_cachep, GFP_KERNEL); |
41 | if (!sd) | 41 | if (!sd) |
42 | return NULL; | 42 | return NULL; |
43 | 43 | ||
44 | memset(sd, 0, sizeof(*sd)); | ||
45 | atomic_set(&sd->s_count, 1); | 44 | atomic_set(&sd->s_count, 1); |
46 | atomic_set(&sd->s_event, 1); | 45 | atomic_set(&sd->s_event, 1); |
47 | INIT_LIST_HEAD(&sd->s_children); | 46 | INIT_LIST_HEAD(&sd->s_children); |