ALSA: info: Avoid leaking kernel memory
authorTakashi Iwai <tiwai@suse.de>
Wed, 13 Mar 2013 11:01:13 +0000 (12:01 +0100)
committerTakashi Iwai <tiwai@suse.de>
Wed, 13 Mar 2013 11:03:33 +0000 (12:03 +0100)
Make sure that the allocated buffer for reading the proc file won't
expose the uncleared kernel memory.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/info.c

index db308dbc8911d72b2dd08d34b09ed7b5792aca43..58e97b35ccebbc6d095e38e8dc6547b14c3c19ca 100644 (file)
@@ -89,7 +89,7 @@ static int resize_info_buffer(struct snd_info_buffer *buffer,
        char *nbuf;
 
        nsize = PAGE_ALIGN(nsize);
-       nbuf = krealloc(buffer->buffer, nsize, GFP_KERNEL);
+       nbuf = krealloc(buffer->buffer, nsize, GFP_KERNEL | __GFP_ZERO);
        if (! nbuf)
                return -ENOMEM;
 
@@ -353,7 +353,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file)
                                goto __nomem;
                        data->rbuffer = buffer;
                        buffer->len = PAGE_SIZE;
-                       buffer->buffer = kmalloc(buffer->len, GFP_KERNEL);
+                       buffer->buffer = kzalloc(buffer->len, GFP_KERNEL);
                        if (buffer->buffer == NULL)
                                goto __nomem;
                }