aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl17
-rw-r--r--include/sound/core.h9
-rw-r--r--include/sound/driver.h4
-rw-r--r--sound/core/memory.c53
-rw-r--r--sound/core/misc.c9
-rw-r--r--sound/core/sound.c5
-rw-r--r--sound/core/wrappers.c10
-rw-r--r--sound/drivers/mpu401/mpu401_uart.c5
-rw-r--r--sound/drivers/mtpav.c5
-rw-r--r--sound/drivers/opl3/opl3_lib.c10
-rw-r--r--sound/drivers/opl4/opl4_lib.c10
-rw-r--r--sound/drivers/serial-u16550.c5
-rw-r--r--sound/drivers/vx/vx_pcm.c4
-rw-r--r--sound/isa/ad1816a/ad1816a_lib.c5
-rw-r--r--sound/isa/ad1848/ad1848_lib.c5
-rw-r--r--sound/isa/cs423x/cs4231_lib.c10
-rw-r--r--sound/isa/cs423x/cs4236.c8
-rw-r--r--sound/isa/es1688/es1688_lib.c3
-rw-r--r--sound/isa/es18xx.c15
-rw-r--r--sound/isa/gus/gus_main.c10
-rw-r--r--sound/isa/gus/interwave.c5
-rw-r--r--sound/isa/opl3sa2.c5
-rw-r--r--sound/isa/opti9xx/opti92x-ad1848.c25
-rw-r--r--sound/isa/sb/emu8000.c15
-rw-r--r--sound/isa/sb/sb16.c5
-rw-r--r--sound/isa/sb/sb8.c5
-rw-r--r--sound/isa/sb/sb_common.c6
-rw-r--r--sound/isa/sscape.c6
-rw-r--r--sound/isa/wavefront/wavefront.c5
-rw-r--r--sound/mips/au1x00.c3
-rw-r--r--sound/pci/als4000.c6
-rw-r--r--sound/pci/azt3328.c6
-rw-r--r--sound/pci/ca0106/ca0106_main.c6
-rw-r--r--sound/pci/cmipci.c6
-rw-r--r--sound/pci/cs46xx/cs46xx_lib.c5
-rw-r--r--sound/pci/emu10k1/emu10k1x.c6
-rw-r--r--sound/pci/es1968.c6
-rw-r--r--sound/pci/nm256/nm256.c10
-rw-r--r--sound/pci/sonicvibes.c10
-rw-r--r--sound/pci/via82xx.c11
-rw-r--r--sound/pci/ymfpci/ymfpci.c16
-rw-r--r--sound/pci/ymfpci/ymfpci_main.c15
-rw-r--r--sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c6
-rw-r--r--sound/usb/usbaudio.c6
44 files changed, 86 insertions, 311 deletions
diff --git a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
index ab3dfe074fb1..05ae29ac898c 100644
--- a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
+++ b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
@@ -1433,25 +1433,10 @@
1433 <informalexample> 1433 <informalexample>
1434 <programlisting> 1434 <programlisting>
1435<![CDATA[ 1435<![CDATA[
1436 if (chip->res_port) { 1436 release_and_free_resource(chip->res_port);
1437 release_resource(chip->res_port);
1438 kfree_nocheck(chip->res_port);
1439 }
1440]]> 1437]]>
1441 </programlisting> 1438 </programlisting>
1442 </informalexample> 1439 </informalexample>
1443
1444 As you can see, the resource pointer is also to be freed
1445 via <function>kfree_nocheck()</function> after
1446 <function>release_resource()</function> is called. You
1447 cannot use <function>kfree()</function> here, because on ALSA,
1448 <function>kfree()</function> may be a wrapper to its own
1449 allocator with the memory debugging. Since the resource pointer
1450 is allocated externally outside the ALSA, it must be released
1451 via the native
1452 <function>kfree()</function>.
1453 <function>kfree_nocheck()</function> is used for that; it calls
1454 the native <function>kfree()</function> without wrapper.
1455 </para> 1440 </para>
1456 1441
1457 <para> 1442 <para>
diff --git a/include/sound/core.h b/include/sound/core.h
index af314205635d..0a14885fb1d7 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -293,19 +293,13 @@ void *snd_hidden_kmalloc(size_t size, gfp_t flags);
293void *snd_hidden_kzalloc(size_t size, gfp_t flags); 293void *snd_hidden_kzalloc(size_t size, gfp_t flags);
294void *snd_hidden_kcalloc(size_t n, size_t size, gfp_t flags); 294void *snd_hidden_kcalloc(size_t n, size_t size, gfp_t flags);
295void snd_hidden_kfree(const void *obj); 295void snd_hidden_kfree(const void *obj);
296void *snd_hidden_vmalloc(unsigned long size);
297void snd_hidden_vfree(void *obj);
298char *snd_hidden_kstrdup(const char *s, gfp_t flags); 296char *snd_hidden_kstrdup(const char *s, gfp_t flags);
299#define kmalloc(size, flags) snd_hidden_kmalloc(size, flags) 297#define kmalloc(size, flags) snd_hidden_kmalloc(size, flags)
300#define kzalloc(size, flags) snd_hidden_kzalloc(size, flags) 298#define kzalloc(size, flags) snd_hidden_kzalloc(size, flags)
301#define kcalloc(n, size, flags) snd_hidden_kcalloc(n, size, flags) 299#define kcalloc(n, size, flags) snd_hidden_kcalloc(n, size, flags)
302#define kfree(obj) snd_hidden_kfree(obj) 300#define kfree(obj) snd_hidden_kfree(obj)
303#define vmalloc(size) snd_hidden_vmalloc(size)
304#define vfree(obj) snd_hidden_vfree(obj)
305#define kmalloc_nocheck(size, flags) snd_wrapper_kmalloc(size, flags) 301#define kmalloc_nocheck(size, flags) snd_wrapper_kmalloc(size, flags)
306#define vmalloc_nocheck(size) snd_wrapper_vmalloc(size)
307#define kfree_nocheck(obj) snd_wrapper_kfree(obj) 302#define kfree_nocheck(obj) snd_wrapper_kfree(obj)
308#define vfree_nocheck(obj) snd_wrapper_vfree(obj)
309#define kstrdup(s, flags) snd_hidden_kstrdup(s, flags) 303#define kstrdup(s, flags) snd_hidden_kstrdup(s, flags)
310#else 304#else
311#define snd_memory_init() /*NOP*/ 305#define snd_memory_init() /*NOP*/
@@ -313,9 +307,7 @@ char *snd_hidden_kstrdup(const char *s, gfp_t flags);
313#define snd_memory_info_init() /*NOP*/ 307#define snd_memory_info_init() /*NOP*/
314#define snd_memory_info_done() /*NOP*/ 308#define snd_memory_info_done() /*NOP*/
315#define kmalloc_nocheck(size, flags) kmalloc(size, flags) 309#define kmalloc_nocheck(size, flags) kmalloc(size, flags)
316#define vmalloc_nocheck(size) vmalloc(size)
317#define kfree_nocheck(obj) kfree(obj) 310#define kfree_nocheck(obj) kfree(obj)
318#define vfree_nocheck(obj) vfree(obj)
319#endif 311#endif
320int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count); 312int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count);
321int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count); 313int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count);
@@ -372,6 +364,7 @@ unsigned int snd_dma_pointer(unsigned long dma, unsigned int size);
372#endif 364#endif
373 365
374/* misc.c */ 366/* misc.c */
367void release_and_free_resource(struct resource *res);
375 368
376#ifdef CONFIG_SND_VERBOSE_PRINTK 369#ifdef CONFIG_SND_VERBOSE_PRINTK
377void snd_verbose_printk(const char *file, int line, const char *format, ...) 370void snd_verbose_printk(const char *file, int line, const char *format, ...)
diff --git a/include/sound/driver.h b/include/sound/driver.h
index 1ec2fae050a6..7973e0c05ae3 100644
--- a/include/sound/driver.h
+++ b/include/sound/driver.h
@@ -55,10 +55,6 @@ void *snd_wrapper_kmalloc(size_t, gfp_t);
55#undef kmalloc 55#undef kmalloc
56void snd_wrapper_kfree(const void *); 56void snd_wrapper_kfree(const void *);
57#undef kfree 57#undef kfree
58void *snd_wrapper_vmalloc(size_t);
59#undef vmalloc
60void snd_wrapper_vfree(void *);
61#undef vfree
62#endif 58#endif
63 59
64#endif /* __SOUND_DRIVER_H */ 60#endif /* __SOUND_DRIVER_H */
diff --git a/sound/core/memory.c b/sound/core/memory.c
index 7d8e2eebba51..b99343616f81 100644
--- a/sound/core/memory.c
+++ b/sound/core/memory.c
@@ -47,19 +47,14 @@ struct snd_alloc_track {
47#define snd_alloc_track_entry(obj) (struct snd_alloc_track *)((char*)obj - (unsigned long)((struct snd_alloc_track *)0)->data) 47#define snd_alloc_track_entry(obj) (struct snd_alloc_track *)((char*)obj - (unsigned long)((struct snd_alloc_track *)0)->data)
48 48
49static long snd_alloc_kmalloc; 49static long snd_alloc_kmalloc;
50static long snd_alloc_vmalloc;
51static LIST_HEAD(snd_alloc_kmalloc_list); 50static LIST_HEAD(snd_alloc_kmalloc_list);
52static LIST_HEAD(snd_alloc_vmalloc_list);
53static DEFINE_SPINLOCK(snd_alloc_kmalloc_lock); 51static DEFINE_SPINLOCK(snd_alloc_kmalloc_lock);
54static DEFINE_SPINLOCK(snd_alloc_vmalloc_lock);
55#define KMALLOC_MAGIC 0x87654321 52#define KMALLOC_MAGIC 0x87654321
56#define VMALLOC_MAGIC 0x87654320
57static snd_info_entry_t *snd_memory_info_entry; 53static snd_info_entry_t *snd_memory_info_entry;
58 54
59void __init snd_memory_init(void) 55void __init snd_memory_init(void)
60{ 56{
61 snd_alloc_kmalloc = 0; 57 snd_alloc_kmalloc = 0;
62 snd_alloc_vmalloc = 0;
63} 58}
64 59
65void snd_memory_done(void) 60void snd_memory_done(void)
@@ -69,8 +64,6 @@ void snd_memory_done(void)
69 64
70 if (snd_alloc_kmalloc > 0) 65 if (snd_alloc_kmalloc > 0)
71 snd_printk(KERN_ERR "Not freed snd_alloc_kmalloc = %li\n", snd_alloc_kmalloc); 66 snd_printk(KERN_ERR "Not freed snd_alloc_kmalloc = %li\n", snd_alloc_kmalloc);
72 if (snd_alloc_vmalloc > 0)
73 snd_printk(KERN_ERR "Not freed snd_alloc_vmalloc = %li\n", snd_alloc_vmalloc);
74 list_for_each_prev(head, &snd_alloc_kmalloc_list) { 67 list_for_each_prev(head, &snd_alloc_kmalloc_list) {
75 t = list_entry(head, struct snd_alloc_track, list); 68 t = list_entry(head, struct snd_alloc_track, list);
76 if (t->magic != KMALLOC_MAGIC) { 69 if (t->magic != KMALLOC_MAGIC) {
@@ -79,14 +72,6 @@ void snd_memory_done(void)
79 } 72 }
80 snd_printk(KERN_ERR "kmalloc(%ld) from %p not freed\n", (long) t->size, t->caller); 73 snd_printk(KERN_ERR "kmalloc(%ld) from %p not freed\n", (long) t->size, t->caller);
81 } 74 }
82 list_for_each_prev(head, &snd_alloc_vmalloc_list) {
83 t = list_entry(head, struct snd_alloc_track, list);
84 if (t->magic != VMALLOC_MAGIC) {
85 snd_printk(KERN_ERR "Corrupted vmalloc\n");
86 break;
87 }
88 snd_printk(KERN_ERR "vmalloc(%ld) from %p not freed\n", (long) t->size, t->caller);
89 }
90} 75}
91 76
92static void *__snd_kmalloc(size_t size, gfp_t flags, void *caller) 77static void *__snd_kmalloc(size_t size, gfp_t flags, void *caller)
@@ -153,43 +138,6 @@ void snd_hidden_kfree(const void *obj)
153 snd_wrapper_kfree(obj); 138 snd_wrapper_kfree(obj);
154} 139}
155 140
156void *snd_hidden_vmalloc(unsigned long size)
157{
158 void *ptr;
159 ptr = snd_wrapper_vmalloc(size + sizeof(struct snd_alloc_track));
160 if (ptr) {
161 struct snd_alloc_track *t = (struct snd_alloc_track *)ptr;
162 t->magic = VMALLOC_MAGIC;
163 t->caller = __builtin_return_address(0);
164 spin_lock(&snd_alloc_vmalloc_lock);
165 list_add_tail(&t->list, &snd_alloc_vmalloc_list);
166 spin_unlock(&snd_alloc_vmalloc_lock);
167 t->size = size;
168 snd_alloc_vmalloc += size;
169 ptr = t->data;
170 }
171 return ptr;
172}
173
174void snd_hidden_vfree(void *obj)
175{
176 struct snd_alloc_track *t;
177 if (obj == NULL)
178 return;
179 t = snd_alloc_track_entry(obj);
180 if (t->magic != VMALLOC_MAGIC) {
181 snd_printk(KERN_ERR "bad vfree (called from %p)\n", __builtin_return_address(0));
182 return;
183 }
184 spin_lock(&snd_alloc_vmalloc_lock);
185 list_del(&t->list);
186 spin_unlock(&snd_alloc_vmalloc_lock);
187 t->magic = 0;
188 snd_alloc_vmalloc -= t->size;
189 obj = t;
190 snd_wrapper_vfree(obj);
191}
192
193char *snd_hidden_kstrdup(const char *s, gfp_t flags) 141char *snd_hidden_kstrdup(const char *s, gfp_t flags)
194{ 142{
195 int len; 143 int len;
@@ -207,7 +155,6 @@ char *snd_hidden_kstrdup(const char *s, gfp_t flags)
207static void snd_memory_info_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer) 155static void snd_memory_info_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer)
208{ 156{
209 snd_iprintf(buffer, "kmalloc: %li bytes\n", snd_alloc_kmalloc); 157 snd_iprintf(buffer, "kmalloc: %li bytes\n", snd_alloc_kmalloc);
210 snd_iprintf(buffer, "vmalloc: %li bytes\n", snd_alloc_vmalloc);
211} 158}
212 159
213int __init snd_memory_info_init(void) 160int __init snd_memory_info_init(void)
diff --git a/sound/core/misc.c b/sound/core/misc.c
index 11a7675b719b..3eddfdede9f3 100644
--- a/sound/core/misc.c
+++ b/sound/core/misc.c
@@ -23,8 +23,17 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/sched.h> 24#include <linux/sched.h>
25#include <linux/time.h> 25#include <linux/time.h>
26#include <linux/ioport.h>
26#include <sound/core.h> 27#include <sound/core.h>
27 28
29void release_and_free_resource(struct resource *res)
30{
31 if (res) {
32 release_resource(res);
33 kfree_nocheck(res);
34 }
35}
36
28#ifdef CONFIG_SND_VERBOSE_PRINTK 37#ifdef CONFIG_SND_VERBOSE_PRINTK
29void snd_verbose_printk(const char *file, int line, const char *format, ...) 38void snd_verbose_printk(const char *file, int line, const char *format, ...)
30{ 39{
diff --git a/sound/core/sound.c b/sound/core/sound.c
index bc8ad0017984..e94eebd8ad6f 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -407,8 +407,6 @@ EXPORT_SYMBOL(snd_unregister_oss_device);
407EXPORT_SYMBOL(snd_hidden_kmalloc); 407EXPORT_SYMBOL(snd_hidden_kmalloc);
408EXPORT_SYMBOL(snd_hidden_kcalloc); 408EXPORT_SYMBOL(snd_hidden_kcalloc);
409EXPORT_SYMBOL(snd_hidden_kfree); 409EXPORT_SYMBOL(snd_hidden_kfree);
410EXPORT_SYMBOL(snd_hidden_vmalloc);
411EXPORT_SYMBOL(snd_hidden_vfree);
412EXPORT_SYMBOL(snd_hidden_kstrdup); 410EXPORT_SYMBOL(snd_hidden_kstrdup);
413#endif 411#endif
414EXPORT_SYMBOL(copy_to_user_fromio); 412EXPORT_SYMBOL(copy_to_user_fromio);
@@ -487,6 +485,7 @@ EXPORT_SYMBOL(snd_ctl_unregister_ioctl_compat);
487EXPORT_SYMBOL(snd_ctl_elem_read); 485EXPORT_SYMBOL(snd_ctl_elem_read);
488EXPORT_SYMBOL(snd_ctl_elem_write); 486EXPORT_SYMBOL(snd_ctl_elem_write);
489 /* misc.c */ 487 /* misc.c */
488EXPORT_SYMBOL(release_and_free_resource);
490#ifdef CONFIG_SND_VERBOSE_PRINTK 489#ifdef CONFIG_SND_VERBOSE_PRINTK
491EXPORT_SYMBOL(snd_verbose_printk); 490EXPORT_SYMBOL(snd_verbose_printk);
492#endif 491#endif
@@ -497,6 +496,4 @@ EXPORT_SYMBOL(snd_verbose_printd);
497#ifdef CONFIG_SND_DEBUG_MEMORY 496#ifdef CONFIG_SND_DEBUG_MEMORY
498EXPORT_SYMBOL(snd_wrapper_kmalloc); 497EXPORT_SYMBOL(snd_wrapper_kmalloc);
499EXPORT_SYMBOL(snd_wrapper_kfree); 498EXPORT_SYMBOL(snd_wrapper_kfree);
500EXPORT_SYMBOL(snd_wrapper_vmalloc);
501EXPORT_SYMBOL(snd_wrapper_vfree);
502#endif 499#endif
diff --git a/sound/core/wrappers.c b/sound/core/wrappers.c
index 296b716f1376..19e899089cb3 100644
--- a/sound/core/wrappers.c
+++ b/sound/core/wrappers.c
@@ -36,15 +36,5 @@ void snd_wrapper_kfree(const void *obj)
36{ 36{
37 kfree(obj); 37 kfree(obj);
38} 38}
39
40void *snd_wrapper_vmalloc(unsigned long size)
41{
42 return vmalloc(size);
43}
44
45void snd_wrapper_vfree(void *obj)
46{
47 vfree(obj);
48}
49#endif 39#endif
50 40
diff --git a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c
index fe3f921ffbe3..bdeb2c00dac5 100644
--- a/sound/drivers/mpu401/mpu401_uart.c
+++ b/sound/drivers/mpu401/mpu401_uart.c
@@ -423,10 +423,7 @@ static void snd_mpu401_uart_free(snd_rawmidi_t *rmidi)
423 mpu401_t *mpu = rmidi->private_data; 423 mpu401_t *mpu = rmidi->private_data;
424 if (mpu->irq_flags && mpu->irq >= 0) 424 if (mpu->irq_flags && mpu->irq >= 0)
425 free_irq(mpu->irq, (void *) mpu); 425 free_irq(mpu->irq, (void *) mpu);
426 if (mpu->res) { 426 release_and_free_resource(mpu->res);
427 release_resource(mpu->res);
428 kfree_nocheck(mpu->res);
429 }
430 kfree(mpu); 427 kfree(mpu);
431} 428}
432 429
diff --git a/sound/drivers/mtpav.c b/sound/drivers/mtpav.c
index 3a25c89d2983..e9d52c668edc 100644
--- a/sound/drivers/mtpav.c
+++ b/sound/drivers/mtpav.c
@@ -717,10 +717,7 @@ static void free_mtpav(mtpav_t * crd)
717 spin_unlock_irqrestore(&crd->spinlock, flags); 717 spin_unlock_irqrestore(&crd->spinlock, flags);
718 if (crd->irq >= 0) 718 if (crd->irq >= 0)
719 free_irq(crd->irq, (void *)crd); 719 free_irq(crd->irq, (void *)crd);
720 if (crd->res_port) { 720 release_and_free_resource(crd->res_port);
721 release_resource(crd->res_port);
722 kfree_nocheck(crd->res_port);
723 }
724 kfree(crd); 721 kfree(crd);
725} 722}
726 723
diff --git a/sound/drivers/opl3/opl3_lib.c b/sound/drivers/opl3/opl3_lib.c
index 1f84d78260de..06246503083c 100644
--- a/sound/drivers/opl3/opl3_lib.c
+++ b/sound/drivers/opl3/opl3_lib.c
@@ -325,14 +325,8 @@ static int snd_opl3_free(opl3_t *opl3)
325 snd_assert(opl3 != NULL, return -ENXIO); 325 snd_assert(opl3 != NULL, return -ENXIO);
326 if (opl3->private_free) 326 if (opl3->private_free)
327 opl3->private_free(opl3); 327 opl3->private_free(opl3);
328 if (opl3->res_l_port) { 328 release_and_free_resource(opl3->res_l_port);
329 release_resource(opl3->res_l_port); 329 release_and_free_resource(opl3->res_r_port);
330 kfree_nocheck(opl3->res_l_port);
331 }
332 if (opl3->res_r_port) {
333 release_resource(opl3->res_r_port);
334 kfree_nocheck(opl3->res_r_port);
335 }
336 kfree(opl3); 330 kfree(opl3);
337 return 0; 331 return 0;
338} 332}
diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
index 380c2c704c54..4ae5dd8f011e 100644
--- a/sound/drivers/opl4/opl4_lib.c
+++ b/sound/drivers/opl4/opl4_lib.c
@@ -169,14 +169,8 @@ static void snd_opl4_free(opl4_t *opl4)
169#ifdef CONFIG_PROC_FS 169#ifdef CONFIG_PROC_FS
170 snd_opl4_free_proc(opl4); 170 snd_opl4_free_proc(opl4);
171#endif 171#endif
172 if (opl4->res_fm_port) { 172 release_and_free_resource(opl4->res_fm_port);
173 release_resource(opl4->res_fm_port); 173 release_and_free_resource(opl4->res_pcm_port);
174 kfree_nocheck(opl4->res_fm_port);
175 }
176 if (opl4->res_pcm_port) {
177 release_resource(opl4->res_pcm_port);
178 kfree_nocheck(opl4->res_pcm_port);
179 }
180 kfree(opl4); 174 kfree(opl4);
181} 175}
182 176
diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c
index 416172ea1f47..1ed58df42671 100644
--- a/sound/drivers/serial-u16550.c
+++ b/sound/drivers/serial-u16550.c
@@ -749,10 +749,7 @@ static int snd_uart16550_free(snd_uart16550_t *uart)
749{ 749{
750 if (uart->irq >= 0) 750 if (uart->irq >= 0)
751 free_irq(uart->irq, (void *)uart); 751 free_irq(uart->irq, (void *)uart);
752 if (uart->res_base) { 752 release_and_free_resource(uart->res_base);
753 release_resource(uart->res_base);
754 kfree_nocheck(uart->res_base);
755 }
756 kfree(uart); 753 kfree(uart);
757 return 0; 754 return 0;
758}; 755};
diff --git a/sound/drivers/vx/vx_pcm.c b/sound/drivers/vx/vx_pcm.c
index c2312d912fc7..2b46758fe86f 100644
--- a/sound/drivers/vx/vx_pcm.c
+++ b/sound/drivers/vx/vx_pcm.c
@@ -79,7 +79,7 @@ static int snd_pcm_alloc_vmalloc_buffer(snd_pcm_substream_t *subs, size_t size)
79 /* already allocated */ 79 /* already allocated */
80 if (runtime->dma_bytes >= size) 80 if (runtime->dma_bytes >= size)
81 return 0; /* already enough large */ 81 return 0; /* already enough large */
82 vfree_nocheck(runtime->dma_area); /* bypass the memory wrapper */ 82 vfree(runtime->dma_area);
83 } 83 }
84 runtime->dma_area = vmalloc_32(size); 84 runtime->dma_area = vmalloc_32(size);
85 if (! runtime->dma_area) 85 if (! runtime->dma_area)
@@ -98,7 +98,7 @@ static int snd_pcm_free_vmalloc_buffer(snd_pcm_substream_t *subs)
98{ 98{
99 snd_pcm_runtime_t *runtime = subs->runtime; 99 snd_pcm_runtime_t *runtime = subs->runtime;
100 if (runtime->dma_area) { 100 if (runtime->dma_area) {
101 vfree_nocheck(runtime->dma_area); /* bypass the memory wrapper */ 101 vfree(runtime->dma_area);
102 runtime->dma_area = NULL; 102 runtime->dma_area = NULL;
103 } 103 }
104 return 0; 104 return 0;
diff --git a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c
index 27a9dcfbba00..7ae02396cae2 100644
--- a/sound/isa/ad1816a/ad1816a_lib.c
+++ b/sound/isa/ad1816a/ad1816a_lib.c
@@ -542,10 +542,7 @@ static int snd_ad1816a_probe(ad1816a_t *chip)
542 542
543static int snd_ad1816a_free(ad1816a_t *chip) 543static int snd_ad1816a_free(ad1816a_t *chip)
544{ 544{
545 if (chip->res_port) { 545 release_and_free_resource(chip->res_port);
546 release_resource(chip->res_port);
547 kfree_nocheck(chip->res_port);
548 }
549 if (chip->irq >= 0) 546 if (chip->irq >= 0)
550 free_irq(chip->irq, (void *) chip); 547 free_irq(chip->irq, (void *) chip);
551 if (chip->dma1 >= 0) { 548 if (chip->dma1 >= 0) {
diff --git a/sound/isa/ad1848/ad1848_lib.c b/sound/isa/ad1848/ad1848_lib.c
index 303861cd03cd..0c2924dfefaf 100644
--- a/sound/isa/ad1848/ad1848_lib.c
+++ b/sound/isa/ad1848/ad1848_lib.c
@@ -846,10 +846,7 @@ static int snd_ad1848_capture_close(snd_pcm_substream_t * substream)
846 846
847static int snd_ad1848_free(ad1848_t *chip) 847static int snd_ad1848_free(ad1848_t *chip)
848{ 848{
849 if (chip->res_port) { 849 release_and_free_resource(chip->res_port);
850 release_resource(chip->res_port);
851 kfree_nocheck(chip->res_port);
852 }
853 if (chip->irq >= 0) 850 if (chip->irq >= 0)
854 free_irq(chip->irq, (void *) chip); 851 free_irq(chip->irq, (void *) chip);
855 if (chip->dma >= 0) { 852 if (chip->dma >= 0) {
diff --git a/sound/isa/cs423x/cs4231_lib.c b/sound/isa/cs423x/cs4231_lib.c
index 32318258cd8e..4af769030beb 100644
--- a/sound/isa/cs423x/cs4231_lib.c
+++ b/sound/isa/cs423x/cs4231_lib.c
@@ -1417,14 +1417,8 @@ static int snd_cs4231_pm_resume(snd_card_t *card)
1417 1417
1418static int snd_cs4231_free(cs4231_t *chip) 1418static int snd_cs4231_free(cs4231_t *chip)
1419{ 1419{
1420 if (chip->res_port) { 1420 release_and_free_resource(chip->res_port);
1421 release_resource(chip->res_port); 1421 release_and_free_resource(chip->res_cport);
1422 kfree_nocheck(chip->res_port);
1423 }
1424 if (chip->res_cport) {
1425 release_resource(chip->res_cport);
1426 kfree_nocheck(chip->res_cport);
1427 }
1428 if (chip->irq >= 0) { 1422 if (chip->irq >= 0) {
1429 disable_irq(chip->irq); 1423 disable_irq(chip->irq);
1430 if (!(chip->hwshare & CS4231_HWSHARE_IRQ)) 1424 if (!(chip->hwshare & CS4231_HWSHARE_IRQ))
diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c
index d28315dc72f7..d60a55e6a0b1 100644
--- a/sound/isa/cs423x/cs4236.c
+++ b/sound/isa/cs423x/cs4236.c
@@ -379,12 +379,8 @@ static void snd_card_cs4236_free(snd_card_t *card)
379{ 379{
380 struct snd_card_cs4236 *acard = (struct snd_card_cs4236 *)card->private_data; 380 struct snd_card_cs4236 *acard = (struct snd_card_cs4236 *)card->private_data;
381 381
382 if (acard) { 382 if (acard)
383 if (acard->res_sb_port) { 383 release_and_free_resource(acard->res_sb_port);
384 release_resource(acard->res_sb_port);
385 kfree_nocheck(acard->res_sb_port);
386 }
387 }
388} 384}
389 385
390#ifdef CONFIG_PNP 386#ifdef CONFIG_PNP
diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c
index aac898765c02..2edc9c9f0445 100644
--- a/sound/isa/es1688/es1688_lib.c
+++ b/sound/isa/es1688/es1688_lib.c
@@ -606,8 +606,7 @@ static int snd_es1688_free(es1688_t *chip)
606{ 606{
607 if (chip->res_port) { 607 if (chip->res_port) {
608 snd_es1688_init(chip, 0); 608 snd_es1688_init(chip, 0);
609 release_resource(chip->res_port); 609 release_and_free_resource(chip->res_port);
610 kfree_nocheck(chip->res_port);
611 } 610 }
612 if (chip->irq >= 0) 611 if (chip->irq >= 0)
613 free_irq(chip->irq, (void *) chip); 612 free_irq(chip->irq, (void *) chip);
diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c
index d0ea19f42703..f0f8505cd1a5 100644
--- a/sound/isa/es18xx.c
+++ b/sound/isa/es18xx.c
@@ -1640,18 +1640,9 @@ static int snd_es18xx_resume(snd_card_t *card)
1640 1640
1641static int snd_es18xx_free(es18xx_t *chip) 1641static int snd_es18xx_free(es18xx_t *chip)
1642{ 1642{
1643 if (chip->res_port) { 1643 release_and_free_resource(chip->res_port);
1644 release_resource(chip->res_port); 1644 release_and_free_resource(chip->res_ctrl_port);
1645 kfree_nocheck(chip->res_port); 1645 release_and_free_resource(chip->res_mpu_port);
1646 }
1647 if (chip->res_ctrl_port) {
1648 release_resource(chip->res_ctrl_port);
1649 kfree_nocheck(chip->res_ctrl_port);
1650 }
1651 if (chip->res_mpu_port) {
1652 release_resource(chip->res_mpu_port);
1653 kfree_nocheck(chip->res_mpu_port);
1654 }
1655 if (chip->irq >= 0) 1646 if (chip->irq >= 0)
1656 free_irq(chip->irq, (void *) chip); 1647 free_irq(chip->irq, (void *) chip);
1657 if (chip->dma1 >= 0) { 1648 if (chip->dma1 >= 0) {
diff --git a/sound/isa/gus/gus_main.c b/sound/isa/gus/gus_main.c
index 8f2872f8e8f6..5fd374f052ec 100644
--- a/sound/isa/gus/gus_main.c
+++ b/sound/isa/gus/gus_main.c
@@ -113,14 +113,8 @@ static int snd_gus_free(snd_gus_card_t *gus)
113 snd_gf1_stop(gus); 113 snd_gf1_stop(gus);
114 snd_gus_init_dma_irq(gus, 0); 114 snd_gus_init_dma_irq(gus, 0);
115 __hw_end: 115 __hw_end:
116 if (gus->gf1.res_port1) { 116 release_and_free_resource(gus->gf1.res_port1);
117 release_resource(gus->gf1.res_port1); 117 release_and_free_resource(gus->gf1.res_port2);
118 kfree_nocheck(gus->gf1.res_port1);
119 }
120 if (gus->gf1.res_port2) {
121 release_resource(gus->gf1.res_port2);
122 kfree_nocheck(gus->gf1.res_port2);
123 }
124 if (gus->gf1.irq >= 0) 118 if (gus->gf1.irq >= 0)
125 free_irq(gus->gf1.irq, (void *) gus); 119 free_irq(gus->gf1.irq, (void *) gus);
126 if (gus->gf1.dma1 >= 0) { 120 if (gus->gf1.dma1 >= 0) {
diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c
index 358cba9d738f..b101ab0a0dbf 100644
--- a/sound/isa/gus/interwave.c
+++ b/sound/isa/gus/interwave.c
@@ -638,10 +638,7 @@ static void snd_interwave_free(snd_card_t *card)
638 if (iwcard == NULL) 638 if (iwcard == NULL)
639 return; 639 return;
640#ifdef SNDRV_STB 640#ifdef SNDRV_STB
641 if (iwcard->i2c_res) { 641 release_and_free_resource(iwcard->i2c_res);
642 release_resource(iwcard->i2c_res);
643 kfree_nocheck(iwcard->i2c_res);
644 }
645#endif 642#endif
646 if (iwcard->irq >= 0) 643 if (iwcard->irq >= 0)
647 free_irq(iwcard->irq, (void *)iwcard); 644 free_irq(iwcard->irq, (void *)iwcard);
diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c
index 4ba268f251e3..47cabda792b6 100644
--- a/sound/isa/opl3sa2.c
+++ b/sound/isa/opl3sa2.c
@@ -656,10 +656,7 @@ static int snd_opl3sa2_free(opl3sa2_t *chip)
656{ 656{
657 if (chip->irq >= 0) 657 if (chip->irq >= 0)
658 free_irq(chip->irq, (void *)chip); 658 free_irq(chip->irq, (void *)chip);
659 if (chip->res_port) { 659 release_and_free_resource(chip->res_port);
660 release_resource(chip->res_port);
661 kfree_nocheck(chip->res_port);
662 }
663 kfree(chip); 660 kfree(chip);
664 return 0; 661 return 0;
665} 662}
diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c
index 73573cb1db6a..b94339f8306f 100644
--- a/sound/isa/opti9xx/opti92x-ad1848.c
+++ b/sound/isa/opti9xx/opti92x-ad1848.c
@@ -299,10 +299,8 @@ static char * snd_opti9xx_names[] = {
299static long snd_legacy_find_free_ioport(long *port_table, long size) 299static long snd_legacy_find_free_ioport(long *port_table, long size)
300{ 300{
301 while (*port_table != -1) { 301 while (*port_table != -1) {
302 struct resource *res; 302 if (request_region(*port_table, size, "ALSA test")) {
303 if ((res = request_region(*port_table, size, "ALSA test")) != NULL) { 303 release_region(*port_table, size);
304 release_resource(res);
305 kfree_nocheck(res);
306 return *port_table; 304 return *port_table;
307 } 305 }
308 port_table++; 306 port_table++;
@@ -1227,10 +1225,7 @@ static int snd_opti93x_probe(opti93x_t *chip)
1227 1225
1228static int snd_opti93x_free(opti93x_t *chip) 1226static int snd_opti93x_free(opti93x_t *chip)
1229{ 1227{
1230 if (chip->res_port) { 1228 release_and_free_resource(chip->res_port);
1231 release_resource(chip->res_port);
1232 kfree_nocheck(chip->res_port);
1233 }
1234 if (chip->dma1 >= 0) { 1229 if (chip->dma1 >= 0) {
1235 disable_dma(chip->dma1); 1230 disable_dma(chip->dma1);
1236 free_dma(chip->dma1); 1231 free_dma(chip->dma1);
@@ -1656,8 +1651,7 @@ static int __devinit snd_card_opti9xx_detect(snd_card_t *card, opti9xx_t *chip)
1656 if (value == snd_opti9xx_read(chip, OPTi9XX_MC_REG(1))) 1651 if (value == snd_opti9xx_read(chip, OPTi9XX_MC_REG(1)))
1657 return 1; 1652 return 1;
1658 1653
1659 release_resource(chip->res_mc_base); 1654 release_and_free_resource(chip->res_mc_base);
1660 kfree_nocheck(chip->res_mc_base);
1661 chip->res_mc_base = NULL; 1655 chip->res_mc_base = NULL;
1662 1656
1663 } 1657 }
@@ -1683,8 +1677,7 @@ static int __devinit snd_card_opti9xx_detect(snd_card_t *card, opti9xx_t *chip)
1683 if (snd_opti9xx_read(chip, OPTi9XX_MC_REG(7)) == 0xff - value) 1677 if (snd_opti9xx_read(chip, OPTi9XX_MC_REG(7)) == 0xff - value)
1684 return 1; 1678 return 1;
1685 1679
1686 release_resource(chip->res_mc_base); 1680 release_and_free_resource(chip->res_mc_base);
1687 kfree_nocheck(chip->res_mc_base);
1688 chip->res_mc_base = NULL; 1681 chip->res_mc_base = NULL;
1689 } 1682 }
1690#endif /* OPTi93X */ 1683#endif /* OPTi93X */
@@ -1886,12 +1879,8 @@ static void snd_card_opti9xx_free(snd_card_t *card)
1886{ 1879{
1887 opti9xx_t *chip = (opti9xx_t *)card->private_data; 1880 opti9xx_t *chip = (opti9xx_t *)card->private_data;
1888 1881
1889 if (chip) { 1882 if (chip)
1890 if (chip->res_mc_base) { 1883 release_and_free_resource(chip->res_mc_base);
1891 release_resource(chip->res_mc_base);
1892 kfree_nocheck(chip->res_mc_base);
1893 }
1894 }
1895} 1884}
1896 1885
1897static int snd_card_opti9xx_probe(struct pnp_card_link *pcard, 1886static int snd_card_opti9xx_probe(struct pnp_card_link *pcard,
diff --git a/sound/isa/sb/emu8000.c b/sound/isa/sb/emu8000.c
index 5375705c054b..95540f133199 100644
--- a/sound/isa/sb/emu8000.c
+++ b/sound/isa/sb/emu8000.c
@@ -1054,18 +1054,9 @@ __error:
1054 */ 1054 */
1055static int snd_emu8000_free(emu8000_t *hw) 1055static int snd_emu8000_free(emu8000_t *hw)
1056{ 1056{
1057 if (hw->res_port1) { 1057 release_and_free_resource(hw->res_port1);
1058 release_resource(hw->res_port1); 1058 release_and_free_resource(hw->res_port2);
1059 kfree_nocheck(hw->res_port1); 1059 release_and_free_resource(hw->res_port3);
1060 }
1061 if (hw->res_port2) {
1062 release_resource(hw->res_port2);
1063 kfree_nocheck(hw->res_port2);
1064 }
1065 if (hw->res_port3) {
1066 release_resource(hw->res_port3);
1067 kfree_nocheck(hw->res_port3);
1068 }
1069 kfree(hw); 1060 kfree(hw);
1070 return 0; 1061 return 0;
1071} 1062}
diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c
index 7888783d68f5..c2fa451bc8f0 100644
--- a/sound/isa/sb/sb16.c
+++ b/sound/isa/sb/sb16.c
@@ -345,10 +345,7 @@ static void snd_sb16_free(snd_card_t *card)
345 345
346 if (acard == NULL) 346 if (acard == NULL)
347 return; 347 return;
348 if (acard->fm_res) { 348 release_and_free_resource(acard->fm_res);
349 release_resource(acard->fm_res);
350 kfree_nocheck(acard->fm_res);
351 }
352} 349}
353 350
354#ifdef CONFIG_PNP 351#ifdef CONFIG_PNP
diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c
index c41ac25e85ca..0bc0a3afdabc 100644
--- a/sound/isa/sb/sb8.c
+++ b/sound/isa/sb/sb8.c
@@ -78,10 +78,7 @@ static void snd_sb8_free(snd_card_t *card)
78 78
79 if (acard == NULL) 79 if (acard == NULL)
80 return; 80 return;
81 if (acard->fm_res) { 81 release_and_free_resource(acard->fm_res);
82 release_resource(acard->fm_res);
83 kfree_nocheck(acard->fm_res);
84 }
85} 82}
86 83
87static int __init snd_sb8_probe(int dev) 84static int __init snd_sb8_probe(int dev)
diff --git a/sound/isa/sb/sb_common.c b/sound/isa/sb/sb_common.c
index f0f205ae425f..46b9480669f9 100644
--- a/sound/isa/sb/sb_common.c
+++ b/sound/isa/sb/sb_common.c
@@ -178,10 +178,8 @@ static int snd_sbdsp_probe(sb_t * chip)
178 178
179static int snd_sbdsp_free(sb_t *chip) 179static int snd_sbdsp_free(sb_t *chip)
180{ 180{
181 if (chip->res_port) { 181 if (chip->res_port)
182 release_resource(chip->res_port); 182 release_and_free_resource(chip->res_port);
183 kfree_nocheck(chip->res_port);
184 }
185 if (chip->irq >= 0) 183 if (chip->irq >= 0)
186 free_irq(chip->irq, (void *) chip); 184 free_irq(chip->irq, (void *) chip);
187#ifdef CONFIG_ISA 185#ifdef CONFIG_ISA
diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c
index 9f6b58c79209..1036876146c4 100644
--- a/sound/isa/sscape.c
+++ b/sound/isa/sscape.c
@@ -338,8 +338,7 @@ static inline void activate_ad1845_unsafe(unsigned io_base)
338static void soundscape_free(snd_card_t * c) 338static void soundscape_free(snd_card_t * c)
339{ 339{
340 register struct soundscape *sscape = get_card_soundscape(c); 340 register struct soundscape *sscape = get_card_soundscape(c);
341 release_resource(sscape->io_res); 341 release_and_free_resource(sscape->io_res);
342 kfree_nocheck(sscape->io_res);
343 free_dma(sscape->chip->dma1); 342 free_dma(sscape->chip->dma1);
344} 343}
345 344
@@ -1288,8 +1287,7 @@ static int __devinit create_sscape(const struct params *params, snd_card_t **rca
1288 free_dma(params->dma1); 1287 free_dma(params->dma1);
1289 1288
1290 _release_region: 1289 _release_region:
1291 release_resource(io_res); 1290 release_and_free_resource(io_res);
1292 kfree_nocheck(io_res);
1293 1291
1294 return err; 1292 return err;
1295} 1293}
diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c
index 0a572e0a47e6..1818f1013c3f 100644
--- a/sound/isa/wavefront/wavefront.c
+++ b/sound/isa/wavefront/wavefront.c
@@ -379,10 +379,7 @@ snd_wavefront_free(snd_card_t *card)
379 snd_wavefront_card_t *acard = (snd_wavefront_card_t *)card->private_data; 379 snd_wavefront_card_t *acard = (snd_wavefront_card_t *)card->private_data;
380 380
381 if (acard) { 381 if (acard) {
382 if (acard->wavefront.res_base != NULL) { 382 release_and_free_resource(acard->wavefront.res_base);
383 release_resource(acard->wavefront.res_base);
384 kfree_nocheck(acard->wavefront.res_base);
385 }
386 if (acard->wavefront.irq > 0) 383 if (acard->wavefront.irq > 0)
387 free_irq(acard->wavefront.irq, (void *)acard); 384 free_irq(acard->wavefront.irq, (void *)acard);
388 } 385 }
diff --git a/sound/mips/au1x00.c b/sound/mips/au1x00.c
index 3f9684f1d1d2..b7af85f5bfb4 100644
--- a/sound/mips/au1x00.c
+++ b/sound/mips/au1x00.c
@@ -606,8 +606,7 @@ snd_au1000_free(snd_card_t *card)
606 /* put internal AC97 block into reset */ 606 /* put internal AC97 block into reset */
607 au1000->ac97_ioport->cntrl = AC97C_RS; 607 au1000->ac97_ioport->cntrl = AC97C_RS;
608 au1000->ac97_ioport = NULL; 608 au1000->ac97_ioport = NULL;
609 release_resource(au1000->ac97_res_port); 609 release_and_free_resource(au1000->ac97_res_port);
610 kfree_nocheck(au1000->ac97_res_port);
611 } 610 }
612 611
613 if (au1000->stream[PLAYBACK]->dma >= 0) 612 if (au1000->stream[PLAYBACK]->dma >= 0)
diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c
index 196ec1c61bb4..8a32cd92f62a 100644
--- a/sound/pci/als4000.c
+++ b/sound/pci/als4000.c
@@ -594,8 +594,7 @@ static int __devinit snd_als4000_create_gameport(snd_card_als4000_t *acard, int
594 acard->gameport = gp = gameport_allocate_port(); 594 acard->gameport = gp = gameport_allocate_port();
595 if (!gp) { 595 if (!gp) {
596 printk(KERN_ERR "als4000: cannot allocate memory for gameport\n"); 596 printk(KERN_ERR "als4000: cannot allocate memory for gameport\n");
597 release_resource(r); 597 release_and_free_resource(r);
598 kfree_nocheck(r);
599 return -ENOMEM; 598 return -ENOMEM;
600 } 599 }
601 600
@@ -622,8 +621,7 @@ static void snd_als4000_free_gameport(snd_card_als4000_t *acard)
622 acard->gameport = NULL; 621 acard->gameport = NULL;
623 622
624 snd_als4000_set_addr(acard->gcr, 0, 0, 0, 0); /* disable joystick */ 623 snd_als4000_set_addr(acard->gcr, 0, 0, 0, 0); /* disable joystick */
625 release_resource(r); 624 release_and_free_resource(r);
626 kfree_nocheck(r);
627 } 625 }
628} 626}
629#else 627#else
diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c
index d5261bdec583..dc638f395c02 100644
--- a/sound/pci/azt3328.c
+++ b/sound/pci/azt3328.c
@@ -1238,8 +1238,7 @@ static int __devinit snd_azf3328_config_joystick(azf3328_t *chip, int dev)
1238 chip->gameport = gp = gameport_allocate_port(); 1238 chip->gameport = gp = gameport_allocate_port();
1239 if (!gp) { 1239 if (!gp) {
1240 printk(KERN_ERR "azt3328: cannot allocate memory for gameport\n"); 1240 printk(KERN_ERR "azt3328: cannot allocate memory for gameport\n");
1241 release_resource(r); 1241 release_and_free_resource(r);
1242 kfree_nocheck(r);
1243 return -ENOMEM; 1242 return -ENOMEM;
1244 } 1243 }
1245 1244
@@ -1267,8 +1266,7 @@ static void snd_azf3328_free_joystick(azf3328_t *chip)
1267 /* disable gameport */ 1266 /* disable gameport */
1268 snd_azf3328_io2_write(chip, IDX_IO2_LEGACY_ADDR, 1267 snd_azf3328_io2_write(chip, IDX_IO2_LEGACY_ADDR,
1269 snd_azf3328_io2_read(chip, IDX_IO2_LEGACY_ADDR) & ~LEGACY_JOY); 1268 snd_azf3328_io2_read(chip, IDX_IO2_LEGACY_ADDR) & ~LEGACY_JOY);
1270 release_resource(r); 1269 release_and_free_resource(r);
1271 kfree_nocheck(r);
1272 } 1270 }
1273} 1271}
1274#else 1272#else
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index ba07960921d8..0d9d8923fbbb 100644
--- a/sound/pci/ca0106/ca0106_main.c
+++ b/sound/pci/ca0106/ca0106_main.c
@@ -969,10 +969,8 @@ static int snd_ca0106_free(ca0106_t *chip)
969#endif 969#endif
970 970
971 // release the i/o port 971 // release the i/o port
972 if (chip->res_port) { 972 release_and_free_resource(chip->res_port);
973 release_resource(chip->res_port); 973
974 kfree_nocheck(chip->res_port);
975 }
976 // release the irq 974 // release the irq
977 if (chip->irq >= 0) 975 if (chip->irq >= 0)
978 free_irq(chip->irq, (void *)chip); 976 free_irq(chip->irq, (void *)chip);
diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c
index 316afb78488d..db093bca2cd0 100644
--- a/sound/pci/cmipci.c
+++ b/sound/pci/cmipci.c
@@ -2683,8 +2683,7 @@ static int __devinit snd_cmipci_create_gameport(cmipci_t *cm, int dev)
2683 cm->gameport = gp = gameport_allocate_port(); 2683 cm->gameport = gp = gameport_allocate_port();
2684 if (!gp) { 2684 if (!gp) {
2685 printk(KERN_ERR "cmipci: cannot allocate memory for gameport\n"); 2685 printk(KERN_ERR "cmipci: cannot allocate memory for gameport\n");
2686 release_resource(r); 2686 release_and_free_resource(r);
2687 kfree_nocheck(r);
2688 return -ENOMEM; 2687 return -ENOMEM;
2689 } 2688 }
2690 gameport_set_name(gp, "C-Media Gameport"); 2689 gameport_set_name(gp, "C-Media Gameport");
@@ -2709,8 +2708,7 @@ static void snd_cmipci_free_gameport(cmipci_t *cm)
2709 cm->gameport = NULL; 2708 cm->gameport = NULL;
2710 2709
2711 snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN); 2710 snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN);
2712 release_resource(r); 2711 release_and_free_resource(r);
2713 kfree_nocheck(r);
2714 } 2712 }
2715} 2713}
2716#else 2714#else
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index 6e3855b8b33d..147836f09dcf 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -2906,10 +2906,7 @@ static int snd_cs46xx_free(cs46xx_t *chip)
2906 snd_cs46xx_region_t *region = &chip->region.idx[idx]; 2906 snd_cs46xx_region_t *region = &chip->region.idx[idx];
2907 if (region->remap_addr) 2907 if (region->remap_addr)
2908 iounmap(region->remap_addr); 2908 iounmap(region->remap_addr);
2909 if (region->resource) { 2909 release_and_free_resource(region->resource);
2910 release_resource(region->resource);
2911 kfree_nocheck(region->resource);
2912 }
2913 } 2910 }
2914 if (chip->irq >= 0) 2911 if (chip->irq >= 0)
2915 free_irq(chip->irq, (void *)chip); 2912 free_irq(chip->irq, (void *)chip);
diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c
index ad15755a63c3..cbb689474e7d 100644
--- a/sound/pci/emu10k1/emu10k1x.c
+++ b/sound/pci/emu10k1/emu10k1x.c
@@ -759,10 +759,8 @@ static int snd_emu10k1x_free(emu10k1x_t *chip)
759 outl(HCFG_LOCKSOUNDCACHE, chip->port + HCFG); 759 outl(HCFG_LOCKSOUNDCACHE, chip->port + HCFG);
760 760
761 // release the i/o port 761 // release the i/o port
762 if (chip->res_port) { 762 release_and_free_resource(chip->res_port);
763 release_resource(chip->res_port); 763
764 kfree_nocheck(chip->res_port);
765 }
766 // release the irq 764 // release the irq
767 if (chip->irq >= 0) 765 if (chip->irq >= 0)
768 free_irq(chip->irq, (void *)chip); 766 free_irq(chip->irq, (void *)chip);
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index ecdcada90ca2..1bf094b67469 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -2461,8 +2461,7 @@ static int __devinit snd_es1968_create_gameport(es1968_t *chip, int dev)
2461 chip->gameport = gp = gameport_allocate_port(); 2461 chip->gameport = gp = gameport_allocate_port();
2462 if (!gp) { 2462 if (!gp) {
2463 printk(KERN_ERR "es1968: cannot allocate memory for gameport\n"); 2463 printk(KERN_ERR "es1968: cannot allocate memory for gameport\n");
2464 release_resource(r); 2464 release_and_free_resource(r);
2465 kfree_nocheck(r);
2466 return -ENOMEM; 2465 return -ENOMEM;
2467 } 2466 }
2468 2467
@@ -2488,8 +2487,7 @@ static void snd_es1968_free_gameport(es1968_t *chip)
2488 gameport_unregister_port(chip->gameport); 2487 gameport_unregister_port(chip->gameport);
2489 chip->gameport = NULL; 2488 chip->gameport = NULL;
2490 2489
2491 release_resource(r); 2490 release_and_free_resource(r);
2492 kfree_nocheck(r);
2493 } 2491 }
2494} 2492}
2495#else 2493#else
diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
index 5c55a3b1d121..ebfa38b51128 100644
--- a/sound/pci/nm256/nm256.c
+++ b/sound/pci/nm256/nm256.c
@@ -1347,14 +1347,8 @@ static int snd_nm256_free(nm256_t *chip)
1347 iounmap(chip->cport); 1347 iounmap(chip->cport);
1348 if (chip->buffer) 1348 if (chip->buffer)
1349 iounmap(chip->buffer); 1349 iounmap(chip->buffer);
1350 if (chip->res_cport) { 1350 release_and_free_resource(chip->res_cport);
1351 release_resource(chip->res_cport); 1351 release_and_free_resource(chip->res_buffer);
1352 kfree_nocheck(chip->res_cport);
1353 }
1354 if (chip->res_buffer) {
1355 release_resource(chip->res_buffer);
1356 kfree_nocheck(chip->res_buffer);
1357 }
1358 if (chip->irq >= 0) 1352 if (chip->irq >= 0)
1359 free_irq(chip->irq, (void*)chip); 1353 free_irq(chip->irq, (void*)chip);
1360 1354
diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c
index 1f6c2bfd43fd..4f64814dfef0 100644
--- a/sound/pci/sonicvibes.c
+++ b/sound/pci/sonicvibes.c
@@ -1205,14 +1205,8 @@ static int snd_sonicvibes_free(sonicvibes_t *sonic)
1205 pci_write_config_dword(sonic->pci, 0x48, sonic->dmac_port); 1205 pci_write_config_dword(sonic->pci, 0x48, sonic->dmac_port);
1206 if (sonic->irq >= 0) 1206 if (sonic->irq >= 0)
1207 free_irq(sonic->irq, (void *)sonic); 1207 free_irq(sonic->irq, (void *)sonic);
1208 if (sonic->res_dmaa) { 1208 release_and_free_resource(sonic->res_dmaa);
1209 release_resource(sonic->res_dmaa); 1209 release_and_free_resource(sonic->res_dmac);
1210 kfree_nocheck(sonic->res_dmaa);
1211 }
1212 if (sonic->res_dmac) {
1213 release_resource(sonic->res_dmac);
1214 kfree_nocheck(sonic->res_dmac);
1215 }
1216 pci_release_regions(sonic->pci); 1210 pci_release_regions(sonic->pci);
1217 pci_disable_device(sonic->pci); 1211 pci_disable_device(sonic->pci);
1218 kfree(sonic); 1212 kfree(sonic);
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index b2779fb7d1a9..b0302c369c3d 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -1655,8 +1655,7 @@ static int __devinit snd_via686_create_gameport(via82xx_t *chip, unsigned char *
1655 chip->gameport = gp = gameport_allocate_port(); 1655 chip->gameport = gp = gameport_allocate_port();
1656 if (!gp) { 1656 if (!gp) {
1657 printk(KERN_ERR "via82xx: cannot allocate memory for gameport\n"); 1657 printk(KERN_ERR "via82xx: cannot allocate memory for gameport\n");
1658 release_resource(r); 1658 release_and_free_resource(r);
1659 kfree_nocheck(r);
1660 return -ENOMEM; 1659 return -ENOMEM;
1661 } 1660 }
1662 1661
@@ -1682,8 +1681,7 @@ static void snd_via686_free_gameport(via82xx_t *chip)
1682 1681
1683 gameport_unregister_port(chip->gameport); 1682 gameport_unregister_port(chip->gameport);
1684 chip->gameport = NULL; 1683 chip->gameport = NULL;
1685 release_resource(r); 1684 release_and_free_resource(r);
1686 kfree_nocheck(r);
1687 } 1685 }
1688} 1686}
1689#else 1687#else
@@ -2023,10 +2021,7 @@ static int snd_via82xx_free(via82xx_t *chip)
2023 __end_hw: 2021 __end_hw:
2024 if (chip->irq >= 0) 2022 if (chip->irq >= 0)
2025 free_irq(chip->irq, (void *)chip); 2023 free_irq(chip->irq, (void *)chip);
2026 if (chip->mpu_res) { 2024 release_and_free_resource(chip->mpu_res);
2027 release_resource(chip->mpu_res);
2028 kfree_nocheck(chip->mpu_res);
2029 }
2030 pci_release_regions(chip->pci); 2025 pci_release_regions(chip->pci);
2031 2026
2032 if (chip->chip_type == TYPE_VIA686) { 2027 if (chip->chip_type == TYPE_VIA686) {
diff --git a/sound/pci/ymfpci/ymfpci.c b/sound/pci/ymfpci/ymfpci.c
index 2e69abe51aa9..e50d744ae706 100644
--- a/sound/pci/ymfpci/ymfpci.c
+++ b/sound/pci/ymfpci/ymfpci.c
@@ -130,8 +130,7 @@ static int __devinit snd_ymfpci_create_gameport(ymfpci_t *chip, int dev,
130 chip->gameport = gp = gameport_allocate_port(); 130 chip->gameport = gp = gameport_allocate_port();
131 if (!gp) { 131 if (!gp) {
132 printk(KERN_ERR "ymfpci: cannot allocate memory for gameport\n"); 132 printk(KERN_ERR "ymfpci: cannot allocate memory for gameport\n");
133 release_resource(r); 133 release_and_free_resource(r);
134 kfree_nocheck(r);
135 return -ENOMEM; 134 return -ENOMEM;
136 } 135 }
137 136
@@ -161,8 +160,7 @@ void snd_ymfpci_free_gameport(ymfpci_t *chip)
161 gameport_unregister_port(chip->gameport); 160 gameport_unregister_port(chip->gameport);
162 chip->gameport = NULL; 161 chip->gameport = NULL;
163 162
164 release_resource(r); 163 release_and_free_resource(r);
165 kfree_nocheck(r);
166 } 164 }
167} 165}
168#else 166#else
@@ -267,14 +265,8 @@ static int __devinit snd_card_ymfpci_probe(struct pci_dev *pci,
267 old_legacy_ctrl, 265 old_legacy_ctrl,
268 &chip)) < 0) { 266 &chip)) < 0) {
269 snd_card_free(card); 267 snd_card_free(card);
270 if (mpu_res) { 268 release_and_free_resource(mpu_res);
271 release_resource(mpu_res); 269 release_and_free_resource(fm_res);
272 kfree_nocheck(mpu_res);
273 }
274 if (fm_res) {
275 release_resource(fm_res);
276 kfree_nocheck(fm_res);
277 }
278 return err; 270 return err;
279 } 271 }
280 chip->fm_res = fm_res; 272 chip->fm_res = fm_res;
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
index 2e671ee438c6..c0aaade772d4 100644
--- a/sound/pci/ymfpci/ymfpci_main.c
+++ b/sound/pci/ymfpci/ymfpci_main.c
@@ -2151,14 +2151,8 @@ static int snd_ymfpci_free(ymfpci_t *chip)
2151#ifdef CONFIG_PM 2151#ifdef CONFIG_PM
2152 vfree(chip->saved_regs); 2152 vfree(chip->saved_regs);
2153#endif 2153#endif
2154 if (chip->mpu_res) { 2154 release_and_free_resource(chip->mpu_res);
2155 release_resource(chip->mpu_res); 2155 release_and_free_resource(chip->fm_res);
2156 kfree_nocheck(chip->mpu_res);
2157 }
2158 if (chip->fm_res) {
2159 release_resource(chip->fm_res);
2160 kfree_nocheck(chip->fm_res);
2161 }
2162 snd_ymfpci_free_gameport(chip); 2156 snd_ymfpci_free_gameport(chip);
2163 if (chip->reg_area_virt) 2157 if (chip->reg_area_virt)
2164 iounmap(chip->reg_area_virt); 2158 iounmap(chip->reg_area_virt);
@@ -2167,10 +2161,7 @@ static int snd_ymfpci_free(ymfpci_t *chip)
2167 2161
2168 if (chip->irq >= 0) 2162 if (chip->irq >= 0)
2169 free_irq(chip->irq, (void *)chip); 2163 free_irq(chip->irq, (void *)chip);
2170 if (chip->res_reg_area) { 2164 release_and_free_resource(chip->res_reg_area);
2171 release_resource(chip->res_reg_area);
2172 kfree_nocheck(chip->res_reg_area);
2173 }
2174 2165
2175 pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl); 2166 pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl);
2176 2167
diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c b/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c
index 0a954dc11b73..20b86d8df7a3 100644
--- a/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c
+++ b/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c
@@ -50,9 +50,9 @@ static int snd_pcm_alloc_vmalloc_buffer(snd_pcm_substream_t *subs, size_t size)
50 if (runtime->dma_area) { 50 if (runtime->dma_area) {
51 if (runtime->dma_bytes >= size) 51 if (runtime->dma_bytes >= size)
52 return 0; /* already enough large */ 52 return 0; /* already enough large */
53 vfree_nocheck(runtime->dma_area); 53 vfree(runtime->dma_area);
54 } 54 }
55 runtime->dma_area = vmalloc_nocheck(size); 55 runtime->dma_area = vmalloc_32(size);
56 if (! runtime->dma_area) 56 if (! runtime->dma_area)
57 return -ENOMEM; 57 return -ENOMEM;
58 runtime->dma_bytes = size; 58 runtime->dma_bytes = size;
@@ -67,7 +67,7 @@ static int snd_pcm_free_vmalloc_buffer(snd_pcm_substream_t *subs)
67{ 67{
68 snd_pcm_runtime_t *runtime = subs->runtime; 68 snd_pcm_runtime_t *runtime = subs->runtime;
69 if (runtime->dma_area) { 69 if (runtime->dma_area) {
70 vfree_nocheck(runtime->dma_area); 70 vfree(runtime->dma_area);
71 runtime->dma_area = NULL; 71 runtime->dma_area = NULL;
72 } 72 }
73 return 0; 73 return 0;
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index 5429b169877a..4589c637a25e 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -692,9 +692,9 @@ static int snd_pcm_alloc_vmalloc_buffer(snd_pcm_substream_t *subs, size_t size)
692 if (runtime->dma_area) { 692 if (runtime->dma_area) {
693 if (runtime->dma_bytes >= size) 693 if (runtime->dma_bytes >= size)
694 return 0; /* already large enough */ 694 return 0; /* already large enough */
695 vfree_nocheck(runtime->dma_area); 695 vfree(runtime->dma_area);
696 } 696 }
697 runtime->dma_area = vmalloc_nocheck(size); 697 runtime->dma_area = vmalloc(size);
698 if (! runtime->dma_area) 698 if (! runtime->dma_area)
699 return -ENOMEM; 699 return -ENOMEM;
700 runtime->dma_bytes = size; 700 runtime->dma_bytes = size;
@@ -706,7 +706,7 @@ static int snd_pcm_free_vmalloc_buffer(snd_pcm_substream_t *subs)
706{ 706{
707 snd_pcm_runtime_t *runtime = subs->runtime; 707 snd_pcm_runtime_t *runtime = subs->runtime;
708 if (runtime->dma_area) { 708 if (runtime->dma_area) {
709 vfree_nocheck(runtime->dma_area); 709 vfree(runtime->dma_area);
710 runtime->dma_area = NULL; 710 runtime->dma_area = NULL;
711 } 711 }
712 return 0; 712 return 0;