Commit 8db08ea7e6527eff82d8e45507468003e3cefba3

Authored by Pekka Enberg
Committed by Linus Torvalds
1 parent e915fc497a

[PATCH] ALSA: convert kcalloc to kzalloc

This patch introduces a memory-leak tracking version of kzalloc for ALSA.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Jaroslav Kysela <perex@suse.cz>
Signed-off-by: Jiri Slaby <xslaby@fi.muni.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 3 changed files with 13 additions and 5 deletions Side-by-side Diff

include/sound/core.h
... ... @@ -291,12 +291,14 @@
291 291 int snd_memory_info_init(void);
292 292 int snd_memory_info_done(void);
293 293 void *snd_hidden_kmalloc(size_t size, unsigned int __nocast flags);
  294 +void *snd_hidden_kzalloc(size_t size, unsigned int __nocast flags);
294 295 void *snd_hidden_kcalloc(size_t n, size_t size, unsigned int __nocast flags);
295 296 void snd_hidden_kfree(const void *obj);
296 297 void *snd_hidden_vmalloc(unsigned long size);
297 298 void snd_hidden_vfree(void *obj);
298 299 char *snd_hidden_kstrdup(const char *s, unsigned int __nocast flags);
299 300 #define kmalloc(size, flags) snd_hidden_kmalloc(size, flags)
  301 +#define kzalloc(size, flags) snd_hidden_kzalloc(size, flags)
300 302 #define kcalloc(n, size, flags) snd_hidden_kcalloc(n, size, flags)
301 303 #define kfree(obj) snd_hidden_kfree(obj)
302 304 #define vmalloc(size) snd_hidden_vmalloc(size)
... ... @@ -116,15 +116,21 @@
116 116 return _snd_kmalloc(size, flags);
117 117 }
118 118  
  119 +void *snd_hidden_kzalloc(size_t size, unsigned int __nocast flags)
  120 +{
  121 + void *ret = _snd_kmalloc(size, flags);
  122 + if (ret)
  123 + memset(ret, 0, size);
  124 + return ret;
  125 +}
  126 +EXPORT_SYMBOL(snd_hidden_kzalloc);
  127 +
119 128 void *snd_hidden_kcalloc(size_t n, size_t size, unsigned int __nocast flags)
120 129 {
121 130 void *ret = NULL;
122 131 if (n != 0 && size > INT_MAX / n)
123 132 return ret;
124   - ret = _snd_kmalloc(n * size, flags);
125   - if (ret)
126   - memset(ret, 0, n * size);
127   - return ret;
  133 + return snd_hidden_kzalloc(n * size, flags);
128 134 }
129 135  
130 136 void snd_hidden_kfree(const void *obj)
sound/pci/ali5451/ali5451.c
... ... @@ -2249,7 +2249,7 @@
2249 2249 return -ENXIO;
2250 2250 }
2251 2251  
2252   - if ((codec = kcalloc(1, sizeof(*codec), GFP_KERNEL)) == NULL) {
  2252 + if ((codec = kzalloc(sizeof(*codec), GFP_KERNEL)) == NULL) {
2253 2253 pci_disable_device(pci);
2254 2254 return -ENOMEM;
2255 2255 }