Skip to content

Commit 658c74c

Browse files
rmullicktorvalds
authored andcommitted
drivers/char/mspec.c: use {k,v}zalloc to allocate memory
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>
1 parent 0741273 commit 658c74c

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

‎drivers/char/mspec.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,13 @@ mspec_mmap(struct file *file, struct vm_area_struct *vma,
271271
pages = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
272272
vdata_size = sizeof(struct vma_data) + pages * sizeof(long);
273273
if (vdata_size <= PAGE_SIZE)
274-
vdata = kmalloc(vdata_size, GFP_KERNEL);
274+
vdata = kzalloc(vdata_size, GFP_KERNEL);
275275
else {
276-
vdata = vmalloc(vdata_size);
276+
vdata = vzalloc(vdata_size);
277277
flags = VMD_VMALLOCED;
278278
}
279279
if (!vdata)
280280
return -ENOMEM;
281-
memset(vdata, 0, vdata_size);
282281

283282
vdata->vm_start = vma->vm_start;
284283
vdata->vm_end = vma->vm_end;

0 commit comments

Comments
 (0)