Commit 8db08ea7 authored by Pekka Enberg's avatar Pekka Enberg Committed by Linus Torvalds

[PATCH] ALSA: convert kcalloc to kzalloc

This patch introduces a memory-leak tracking version of kzalloc for ALSA.
Signed-off-by: default avatarPekka Enberg <penberg@cs.helsinki.fi>
Cc: Jaroslav Kysela <perex@suse.cz>
Signed-off-by: default avatarJiri Slaby <xslaby@fi.muni.cz>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent e915fc49
...@@ -291,12 +291,14 @@ void snd_memory_done(void); ...@@ -291,12 +291,14 @@ void snd_memory_done(void);
int snd_memory_info_init(void); int snd_memory_info_init(void);
int snd_memory_info_done(void); int snd_memory_info_done(void);
void *snd_hidden_kmalloc(size_t size, unsigned int __nocast flags); void *snd_hidden_kmalloc(size_t size, unsigned int __nocast flags);
void *snd_hidden_kzalloc(size_t size, unsigned int __nocast flags);
void *snd_hidden_kcalloc(size_t n, size_t size, unsigned int __nocast flags); void *snd_hidden_kcalloc(size_t n, size_t size, unsigned int __nocast flags);
void snd_hidden_kfree(const void *obj); void snd_hidden_kfree(const void *obj);
void *snd_hidden_vmalloc(unsigned long size); void *snd_hidden_vmalloc(unsigned long size);
void snd_hidden_vfree(void *obj); void snd_hidden_vfree(void *obj);
char *snd_hidden_kstrdup(const char *s, unsigned int __nocast flags); char *snd_hidden_kstrdup(const char *s, unsigned int __nocast flags);
#define kmalloc(size, flags) snd_hidden_kmalloc(size, flags) #define kmalloc(size, flags) snd_hidden_kmalloc(size, flags)
#define kzalloc(size, flags) snd_hidden_kzalloc(size, flags)
#define kcalloc(n, size, flags) snd_hidden_kcalloc(n, size, flags) #define kcalloc(n, size, flags) snd_hidden_kcalloc(n, size, flags)
#define kfree(obj) snd_hidden_kfree(obj) #define kfree(obj) snd_hidden_kfree(obj)
#define vmalloc(size) snd_hidden_vmalloc(size) #define vmalloc(size) snd_hidden_vmalloc(size)
......
...@@ -116,15 +116,21 @@ void *snd_hidden_kmalloc(size_t size, unsigned int __nocast flags) ...@@ -116,15 +116,21 @@ void *snd_hidden_kmalloc(size_t size, unsigned int __nocast flags)
return _snd_kmalloc(size, flags); return _snd_kmalloc(size, flags);
} }
void *snd_hidden_kzalloc(size_t size, unsigned int __nocast flags)
{
void *ret = _snd_kmalloc(size, flags);
if (ret)
memset(ret, 0, size);
return ret;
}
EXPORT_SYMBOL(snd_hidden_kzalloc);
void *snd_hidden_kcalloc(size_t n, size_t size, unsigned int __nocast flags) void *snd_hidden_kcalloc(size_t n, size_t size, unsigned int __nocast flags)
{ {
void *ret = NULL; void *ret = NULL;
if (n != 0 && size > INT_MAX / n) if (n != 0 && size > INT_MAX / n)
return ret; return ret;
ret = _snd_kmalloc(n * size, flags); return snd_hidden_kzalloc(n * size, flags);
if (ret)
memset(ret, 0, n * size);
return ret;
} }
void snd_hidden_kfree(const void *obj) void snd_hidden_kfree(const void *obj)
......
...@@ -2249,7 +2249,7 @@ static int __devinit snd_ali_create(snd_card_t * card, ...@@ -2249,7 +2249,7 @@ static int __devinit snd_ali_create(snd_card_t * card,
return -ENXIO; return -ENXIO;
} }
if ((codec = kcalloc(1, sizeof(*codec), GFP_KERNEL)) == NULL) { if ((codec = kzalloc(sizeof(*codec), GFP_KERNEL)) == NULL) {
pci_disable_device(pci); pci_disable_device(pci);
return -ENOMEM; return -ENOMEM;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment