Skip to content

Commit

Permalink
drivers/char/mspec.c: use {k,v}zalloc to allocate memory
Browse files Browse the repository at this point in the history
Let memory allocator initialize the allocated memory as null, thus remove
the use of memset.

Signed-off-by: Rakib Mullick <rakib.mullick@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Rakib Mullick authored and Linus Torvalds committed May 27, 2011
1 parent 0741273 commit 658c74c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/char/mspec.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,13 @@ mspec_mmap(struct file *file, struct vm_area_struct *vma,
pages = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
vdata_size = sizeof(struct vma_data) + pages * sizeof(long);
if (vdata_size <= PAGE_SIZE)
vdata = kmalloc(vdata_size, GFP_KERNEL);
vdata = kzalloc(vdata_size, GFP_KERNEL);
else {
vdata = vmalloc(vdata_size);
vdata = vzalloc(vdata_size);
flags = VMD_VMALLOCED;
}
if (!vdata)
return -ENOMEM;
memset(vdata, 0, vdata_size);

vdata->vm_start = vma->vm_start;
vdata->vm_end = vma->vm_end;
Expand Down

0 comments on commit 658c74c

Please sign in to comment.