<informalexample>
<programlisting>
<![CDATA[
- if (chip->res_port) {
- release_resource(chip->res_port);
- kfree_nocheck(chip->res_port);
- }
+ release_and_free_resource(chip->res_port);
]]>
</programlisting>
</informalexample>
-
- As you can see, the resource pointer is also to be freed
- via <function>kfree_nocheck()</function> after
- <function>release_resource()</function> is called. You
- cannot use <function>kfree()</function> here, because on ALSA,
- <function>kfree()</function> may be a wrapper to its own
- allocator with the memory debugging. Since the resource pointer
- is allocated externally outside the ALSA, it must be released
- via the native
- <function>kfree()</function>.
- <function>kfree_nocheck()</function> is used for that; it calls
- the native <function>kfree()</function> without wrapper.
</para>
<para>
void *snd_hidden_kzalloc(size_t size, gfp_t flags);
void *snd_hidden_kcalloc(size_t n, size_t size, gfp_t flags);
void snd_hidden_kfree(const void *obj);
-void *snd_hidden_vmalloc(unsigned long size);
-void snd_hidden_vfree(void *obj);
char *snd_hidden_kstrdup(const char *s, gfp_t 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 kfree(obj) snd_hidden_kfree(obj)
-#define vmalloc(size) snd_hidden_vmalloc(size)
-#define vfree(obj) snd_hidden_vfree(obj)
#define kmalloc_nocheck(size, flags) snd_wrapper_kmalloc(size, flags)
-#define vmalloc_nocheck(size) snd_wrapper_vmalloc(size)
#define kfree_nocheck(obj) snd_wrapper_kfree(obj)
-#define vfree_nocheck(obj) snd_wrapper_vfree(obj)
#define kstrdup(s, flags) snd_hidden_kstrdup(s, flags)
#else
#define snd_memory_init() /*NOP*/
#define snd_memory_info_init() /*NOP*/
#define snd_memory_info_done() /*NOP*/
#define kmalloc_nocheck(size, flags) kmalloc(size, flags)
-#define vmalloc_nocheck(size) vmalloc(size)
#define kfree_nocheck(obj) kfree(obj)
-#define vfree_nocheck(obj) vfree(obj)
#endif
int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count);
int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count);
#endif
/* misc.c */
+void release_and_free_resource(struct resource *res);
#ifdef CONFIG_SND_VERBOSE_PRINTK
void snd_verbose_printk(const char *file, int line, const char *format, ...)
#undef kmalloc
void snd_wrapper_kfree(const void *);
#undef kfree
-void *snd_wrapper_vmalloc(size_t);
-#undef vmalloc
-void snd_wrapper_vfree(void *);
-#undef vfree
#endif
#endif /* __SOUND_DRIVER_H */
#define snd_alloc_track_entry(obj) (struct snd_alloc_track *)((char*)obj - (unsigned long)((struct snd_alloc_track *)0)->data)
static long snd_alloc_kmalloc;
-static long snd_alloc_vmalloc;
static LIST_HEAD(snd_alloc_kmalloc_list);
-static LIST_HEAD(snd_alloc_vmalloc_list);
static DEFINE_SPINLOCK(snd_alloc_kmalloc_lock);
-static DEFINE_SPINLOCK(snd_alloc_vmalloc_lock);
#define KMALLOC_MAGIC 0x87654321
-#define VMALLOC_MAGIC 0x87654320
static snd_info_entry_t *snd_memory_info_entry;
void __init snd_memory_init(void)
{
snd_alloc_kmalloc = 0;
- snd_alloc_vmalloc = 0;
}
void snd_memory_done(void)
if (snd_alloc_kmalloc > 0)
snd_printk(KERN_ERR "Not freed snd_alloc_kmalloc = %li\n", snd_alloc_kmalloc);
- if (snd_alloc_vmalloc > 0)
- snd_printk(KERN_ERR "Not freed snd_alloc_vmalloc = %li\n", snd_alloc_vmalloc);
list_for_each_prev(head, &snd_alloc_kmalloc_list) {
t = list_entry(head, struct snd_alloc_track, list);
if (t->magic != KMALLOC_MAGIC) {
}
snd_printk(KERN_ERR "kmalloc(%ld) from %p not freed\n", (long) t->size, t->caller);
}
- list_for_each_prev(head, &snd_alloc_vmalloc_list) {
- t = list_entry(head, struct snd_alloc_track, list);
- if (t->magic != VMALLOC_MAGIC) {
- snd_printk(KERN_ERR "Corrupted vmalloc\n");
- break;
- }
- snd_printk(KERN_ERR "vmalloc(%ld) from %p not freed\n", (long) t->size, t->caller);
- }
}
static void *__snd_kmalloc(size_t size, gfp_t flags, void *caller)
snd_wrapper_kfree(obj);
}
-void *snd_hidden_vmalloc(unsigned long size)
-{
- void *ptr;
- ptr = snd_wrapper_vmalloc(size + sizeof(struct snd_alloc_track));
- if (ptr) {
- struct snd_alloc_track *t = (struct snd_alloc_track *)ptr;
- t->magic = VMALLOC_MAGIC;
- t->caller = __builtin_return_address(0);
- spin_lock(&snd_alloc_vmalloc_lock);
- list_add_tail(&t->list, &snd_alloc_vmalloc_list);
- spin_unlock(&snd_alloc_vmalloc_lock);
- t->size = size;
- snd_alloc_vmalloc += size;
- ptr = t->data;
- }
- return ptr;
-}
-
-void snd_hidden_vfree(void *obj)
-{
- struct snd_alloc_track *t;
- if (obj == NULL)
- return;
- t = snd_alloc_track_entry(obj);
- if (t->magic != VMALLOC_MAGIC) {
- snd_printk(KERN_ERR "bad vfree (called from %p)\n", __builtin_return_address(0));
- return;
- }
- spin_lock(&snd_alloc_vmalloc_lock);
- list_del(&t->list);
- spin_unlock(&snd_alloc_vmalloc_lock);
- t->magic = 0;
- snd_alloc_vmalloc -= t->size;
- obj = t;
- snd_wrapper_vfree(obj);
-}
-
char *snd_hidden_kstrdup(const char *s, gfp_t flags)
{
int len;
static void snd_memory_info_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer)
{
snd_iprintf(buffer, "kmalloc: %li bytes\n", snd_alloc_kmalloc);
- snd_iprintf(buffer, "vmalloc: %li bytes\n", snd_alloc_vmalloc);
}
int __init snd_memory_info_init(void)
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/time.h>
+#include <linux/ioport.h>
#include <sound/core.h>
+void release_and_free_resource(struct resource *res)
+{
+ if (res) {
+ release_resource(res);
+ kfree_nocheck(res);
+ }
+}
+
#ifdef CONFIG_SND_VERBOSE_PRINTK
void snd_verbose_printk(const char *file, int line, const char *format, ...)
{
EXPORT_SYMBOL(snd_hidden_kmalloc);
EXPORT_SYMBOL(snd_hidden_kcalloc);
EXPORT_SYMBOL(snd_hidden_kfree);
-EXPORT_SYMBOL(snd_hidden_vmalloc);
-EXPORT_SYMBOL(snd_hidden_vfree);
EXPORT_SYMBOL(snd_hidden_kstrdup);
#endif
EXPORT_SYMBOL(copy_to_user_fromio);
EXPORT_SYMBOL(snd_ctl_elem_read);
EXPORT_SYMBOL(snd_ctl_elem_write);
/* misc.c */
+EXPORT_SYMBOL(release_and_free_resource);
#ifdef CONFIG_SND_VERBOSE_PRINTK
EXPORT_SYMBOL(snd_verbose_printk);
#endif
#ifdef CONFIG_SND_DEBUG_MEMORY
EXPORT_SYMBOL(snd_wrapper_kmalloc);
EXPORT_SYMBOL(snd_wrapper_kfree);
-EXPORT_SYMBOL(snd_wrapper_vmalloc);
-EXPORT_SYMBOL(snd_wrapper_vfree);
#endif
{
kfree(obj);
}
-
-void *snd_wrapper_vmalloc(unsigned long size)
-{
- return vmalloc(size);
-}
-
-void snd_wrapper_vfree(void *obj)
-{
- vfree(obj);
-}
#endif
mpu401_t *mpu = rmidi->private_data;
if (mpu->irq_flags && mpu->irq >= 0)
free_irq(mpu->irq, (void *) mpu);
- if (mpu->res) {
- release_resource(mpu->res);
- kfree_nocheck(mpu->res);
- }
+ release_and_free_resource(mpu->res);
kfree(mpu);
}
spin_unlock_irqrestore(&crd->spinlock, flags);
if (crd->irq >= 0)
free_irq(crd->irq, (void *)crd);
- if (crd->res_port) {
- release_resource(crd->res_port);
- kfree_nocheck(crd->res_port);
- }
+ release_and_free_resource(crd->res_port);
kfree(crd);
}
snd_assert(opl3 != NULL, return -ENXIO);
if (opl3->private_free)
opl3->private_free(opl3);
- if (opl3->res_l_port) {
- release_resource(opl3->res_l_port);
- kfree_nocheck(opl3->res_l_port);
- }
- if (opl3->res_r_port) {
- release_resource(opl3->res_r_port);
- kfree_nocheck(opl3->res_r_port);
- }
+ release_and_free_resource(opl3->res_l_port);
+ release_and_free_resource(opl3->res_r_port);
kfree(opl3);
return 0;
}
#ifdef CONFIG_PROC_FS
snd_opl4_free_proc(opl4);
#endif
- if (opl4->res_fm_port) {
- release_resource(opl4->res_fm_port);
- kfree_nocheck(opl4->res_fm_port);
- }
- if (opl4->res_pcm_port) {
- release_resource(opl4->res_pcm_port);
- kfree_nocheck(opl4->res_pcm_port);
- }
+ release_and_free_resource(opl4->res_fm_port);
+ release_and_free_resource(opl4->res_pcm_port);
kfree(opl4);
}
{
if (uart->irq >= 0)
free_irq(uart->irq, (void *)uart);
- if (uart->res_base) {
- release_resource(uart->res_base);
- kfree_nocheck(uart->res_base);
- }
+ release_and_free_resource(uart->res_base);
kfree(uart);
return 0;
};
/* already allocated */
if (runtime->dma_bytes >= size)
return 0; /* already enough large */
- vfree_nocheck(runtime->dma_area); /* bypass the memory wrapper */
+ vfree(runtime->dma_area);
}
runtime->dma_area = vmalloc_32(size);
if (! runtime->dma_area)
{
snd_pcm_runtime_t *runtime = subs->runtime;
if (runtime->dma_area) {
- vfree_nocheck(runtime->dma_area); /* bypass the memory wrapper */
+ vfree(runtime->dma_area);
runtime->dma_area = NULL;
}
return 0;
static int snd_ad1816a_free(ad1816a_t *chip)
{
- if (chip->res_port) {
- release_resource(chip->res_port);
- kfree_nocheck(chip->res_port);
- }
+ release_and_free_resource(chip->res_port);
if (chip->irq >= 0)
free_irq(chip->irq, (void *) chip);
if (chip->dma1 >= 0) {
static int snd_ad1848_free(ad1848_t *chip)
{
- if (chip->res_port) {
- release_resource(chip->res_port);
- kfree_nocheck(chip->res_port);
- }
+ release_and_free_resource(chip->res_port);
if (chip->irq >= 0)
free_irq(chip->irq, (void *) chip);
if (chip->dma >= 0) {
static int snd_cs4231_free(cs4231_t *chip)
{
- if (chip->res_port) {
- release_resource(chip->res_port);
- kfree_nocheck(chip->res_port);
- }
- if (chip->res_cport) {
- release_resource(chip->res_cport);
- kfree_nocheck(chip->res_cport);
- }
+ release_and_free_resource(chip->res_port);
+ release_and_free_resource(chip->res_cport);
if (chip->irq >= 0) {
disable_irq(chip->irq);
if (!(chip->hwshare & CS4231_HWSHARE_IRQ))
{
struct snd_card_cs4236 *acard = (struct snd_card_cs4236 *)card->private_data;
- if (acard) {
- if (acard->res_sb_port) {
- release_resource(acard->res_sb_port);
- kfree_nocheck(acard->res_sb_port);
- }
- }
+ if (acard)
+ release_and_free_resource(acard->res_sb_port);
}
#ifdef CONFIG_PNP
{
if (chip->res_port) {
snd_es1688_init(chip, 0);
- release_resource(chip->res_port);
- kfree_nocheck(chip->res_port);
+ release_and_free_resource(chip->res_port);
}
if (chip->irq >= 0)
free_irq(chip->irq, (void *) chip);
static int snd_es18xx_free(es18xx_t *chip)
{
- if (chip->res_port) {
- release_resource(chip->res_port);
- kfree_nocheck(chip->res_port);
- }
- if (chip->res_ctrl_port) {
- release_resource(chip->res_ctrl_port);
- kfree_nocheck(chip->res_ctrl_port);
- }
- if (chip->res_mpu_port) {
- release_resource(chip->res_mpu_port);
- kfree_nocheck(chip->res_mpu_port);
- }
+ release_and_free_resource(chip->res_port);
+ release_and_free_resource(chip->res_ctrl_port);
+ release_and_free_resource(chip->res_mpu_port);
if (chip->irq >= 0)
free_irq(chip->irq, (void *) chip);
if (chip->dma1 >= 0) {
snd_gf1_stop(gus);
snd_gus_init_dma_irq(gus, 0);
__hw_end:
- if (gus->gf1.res_port1) {
- release_resource(gus->gf1.res_port1);
- kfree_nocheck(gus->gf1.res_port1);
- }
- if (gus->gf1.res_port2) {
- release_resource(gus->gf1.res_port2);
- kfree_nocheck(gus->gf1.res_port2);
- }
+ release_and_free_resource(gus->gf1.res_port1);
+ release_and_free_resource(gus->gf1.res_port2);
if (gus->gf1.irq >= 0)
free_irq(gus->gf1.irq, (void *) gus);
if (gus->gf1.dma1 >= 0) {
if (iwcard == NULL)
return;
#ifdef SNDRV_STB
- if (iwcard->i2c_res) {
- release_resource(iwcard->i2c_res);
- kfree_nocheck(iwcard->i2c_res);
- }
+ release_and_free_resource(iwcard->i2c_res);
#endif
if (iwcard->irq >= 0)
free_irq(iwcard->irq, (void *)iwcard);
{
if (chip->irq >= 0)
free_irq(chip->irq, (void *)chip);
- if (chip->res_port) {
- release_resource(chip->res_port);
- kfree_nocheck(chip->res_port);
- }
+ release_and_free_resource(chip->res_port);
kfree(chip);
return 0;
}
static long snd_legacy_find_free_ioport(long *port_table, long size)
{
while (*port_table != -1) {
- struct resource *res;
- if ((res = request_region(*port_table, size, "ALSA test")) != NULL) {
- release_resource(res);
- kfree_nocheck(res);
+ if (request_region(*port_table, size, "ALSA test")) {
+ release_region(*port_table, size);
return *port_table;
}
port_table++;
static int snd_opti93x_free(opti93x_t *chip)
{
- if (chip->res_port) {
- release_resource(chip->res_port);
- kfree_nocheck(chip->res_port);
- }
+ release_and_free_resource(chip->res_port);
if (chip->dma1 >= 0) {
disable_dma(chip->dma1);
free_dma(chip->dma1);
if (value == snd_opti9xx_read(chip, OPTi9XX_MC_REG(1)))
return 1;
- release_resource(chip->res_mc_base);
- kfree_nocheck(chip->res_mc_base);
+ release_and_free_resource(chip->res_mc_base);
chip->res_mc_base = NULL;
}
if (snd_opti9xx_read(chip, OPTi9XX_MC_REG(7)) == 0xff - value)
return 1;
- release_resource(chip->res_mc_base);
- kfree_nocheck(chip->res_mc_base);
+ release_and_free_resource(chip->res_mc_base);
chip->res_mc_base = NULL;
}
#endif /* OPTi93X */
{
opti9xx_t *chip = (opti9xx_t *)card->private_data;
- if (chip) {
- if (chip->res_mc_base) {
- release_resource(chip->res_mc_base);
- kfree_nocheck(chip->res_mc_base);
- }
- }
+ if (chip)
+ release_and_free_resource(chip->res_mc_base);
}
static int snd_card_opti9xx_probe(struct pnp_card_link *pcard,
*/
static int snd_emu8000_free(emu8000_t *hw)
{
- if (hw->res_port1) {
- release_resource(hw->res_port1);
- kfree_nocheck(hw->res_port1);
- }
- if (hw->res_port2) {
- release_resource(hw->res_port2);
- kfree_nocheck(hw->res_port2);
- }
- if (hw->res_port3) {
- release_resource(hw->res_port3);
- kfree_nocheck(hw->res_port3);
- }
+ release_and_free_resource(hw->res_port1);
+ release_and_free_resource(hw->res_port2);
+ release_and_free_resource(hw->res_port3);
kfree(hw);
return 0;
}
if (acard == NULL)
return;
- if (acard->fm_res) {
- release_resource(acard->fm_res);
- kfree_nocheck(acard->fm_res);
- }
+ release_and_free_resource(acard->fm_res);
}
#ifdef CONFIG_PNP
if (acard == NULL)
return;
- if (acard->fm_res) {
- release_resource(acard->fm_res);
- kfree_nocheck(acard->fm_res);
- }
+ release_and_free_resource(acard->fm_res);
}
static int __init snd_sb8_probe(int dev)
static int snd_sbdsp_free(sb_t *chip)
{
- if (chip->res_port) {
- release_resource(chip->res_port);
- kfree_nocheck(chip->res_port);
- }
+ if (chip->res_port)
+ release_and_free_resource(chip->res_port);
if (chip->irq >= 0)
free_irq(chip->irq, (void *) chip);
#ifdef CONFIG_ISA
static void soundscape_free(snd_card_t * c)
{
register struct soundscape *sscape = get_card_soundscape(c);
- release_resource(sscape->io_res);
- kfree_nocheck(sscape->io_res);
+ release_and_free_resource(sscape->io_res);
free_dma(sscape->chip->dma1);
}
free_dma(params->dma1);
_release_region:
- release_resource(io_res);
- kfree_nocheck(io_res);
+ release_and_free_resource(io_res);
return err;
}
snd_wavefront_card_t *acard = (snd_wavefront_card_t *)card->private_data;
if (acard) {
- if (acard->wavefront.res_base != NULL) {
- release_resource(acard->wavefront.res_base);
- kfree_nocheck(acard->wavefront.res_base);
- }
+ release_and_free_resource(acard->wavefront.res_base);
if (acard->wavefront.irq > 0)
free_irq(acard->wavefront.irq, (void *)acard);
}
/* put internal AC97 block into reset */
au1000->ac97_ioport->cntrl = AC97C_RS;
au1000->ac97_ioport = NULL;
- release_resource(au1000->ac97_res_port);
- kfree_nocheck(au1000->ac97_res_port);
+ release_and_free_resource(au1000->ac97_res_port);
}
if (au1000->stream[PLAYBACK]->dma >= 0)
acard->gameport = gp = gameport_allocate_port();
if (!gp) {
printk(KERN_ERR "als4000: cannot allocate memory for gameport\n");
- release_resource(r);
- kfree_nocheck(r);
+ release_and_free_resource(r);
return -ENOMEM;
}
acard->gameport = NULL;
snd_als4000_set_addr(acard->gcr, 0, 0, 0, 0); /* disable joystick */
- release_resource(r);
- kfree_nocheck(r);
+ release_and_free_resource(r);
}
}
#else
chip->gameport = gp = gameport_allocate_port();
if (!gp) {
printk(KERN_ERR "azt3328: cannot allocate memory for gameport\n");
- release_resource(r);
- kfree_nocheck(r);
+ release_and_free_resource(r);
return -ENOMEM;
}
/* disable gameport */
snd_azf3328_io2_write(chip, IDX_IO2_LEGACY_ADDR,
snd_azf3328_io2_read(chip, IDX_IO2_LEGACY_ADDR) & ~LEGACY_JOY);
- release_resource(r);
- kfree_nocheck(r);
+ release_and_free_resource(r);
}
}
#else
#endif
// release the i/o port
- if (chip->res_port) {
- release_resource(chip->res_port);
- kfree_nocheck(chip->res_port);
- }
+ release_and_free_resource(chip->res_port);
+
// release the irq
if (chip->irq >= 0)
free_irq(chip->irq, (void *)chip);
cm->gameport = gp = gameport_allocate_port();
if (!gp) {
printk(KERN_ERR "cmipci: cannot allocate memory for gameport\n");
- release_resource(r);
- kfree_nocheck(r);
+ release_and_free_resource(r);
return -ENOMEM;
}
gameport_set_name(gp, "C-Media Gameport");
cm->gameport = NULL;
snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN);
- release_resource(r);
- kfree_nocheck(r);
+ release_and_free_resource(r);
}
}
#else
snd_cs46xx_region_t *region = &chip->region.idx[idx];
if (region->remap_addr)
iounmap(region->remap_addr);
- if (region->resource) {
- release_resource(region->resource);
- kfree_nocheck(region->resource);
- }
+ release_and_free_resource(region->resource);
}
if (chip->irq >= 0)
free_irq(chip->irq, (void *)chip);
outl(HCFG_LOCKSOUNDCACHE, chip->port + HCFG);
// release the i/o port
- if (chip->res_port) {
- release_resource(chip->res_port);
- kfree_nocheck(chip->res_port);
- }
+ release_and_free_resource(chip->res_port);
+
// release the irq
if (chip->irq >= 0)
free_irq(chip->irq, (void *)chip);
chip->gameport = gp = gameport_allocate_port();
if (!gp) {
printk(KERN_ERR "es1968: cannot allocate memory for gameport\n");
- release_resource(r);
- kfree_nocheck(r);
+ release_and_free_resource(r);
return -ENOMEM;
}
gameport_unregister_port(chip->gameport);
chip->gameport = NULL;
- release_resource(r);
- kfree_nocheck(r);
+ release_and_free_resource(r);
}
}
#else
iounmap(chip->cport);
if (chip->buffer)
iounmap(chip->buffer);
- if (chip->res_cport) {
- release_resource(chip->res_cport);
- kfree_nocheck(chip->res_cport);
- }
- if (chip->res_buffer) {
- release_resource(chip->res_buffer);
- kfree_nocheck(chip->res_buffer);
- }
+ release_and_free_resource(chip->res_cport);
+ release_and_free_resource(chip->res_buffer);
if (chip->irq >= 0)
free_irq(chip->irq, (void*)chip);
pci_write_config_dword(sonic->pci, 0x48, sonic->dmac_port);
if (sonic->irq >= 0)
free_irq(sonic->irq, (void *)sonic);
- if (sonic->res_dmaa) {
- release_resource(sonic->res_dmaa);
- kfree_nocheck(sonic->res_dmaa);
- }
- if (sonic->res_dmac) {
- release_resource(sonic->res_dmac);
- kfree_nocheck(sonic->res_dmac);
- }
+ release_and_free_resource(sonic->res_dmaa);
+ release_and_free_resource(sonic->res_dmac);
pci_release_regions(sonic->pci);
pci_disable_device(sonic->pci);
kfree(sonic);
chip->gameport = gp = gameport_allocate_port();
if (!gp) {
printk(KERN_ERR "via82xx: cannot allocate memory for gameport\n");
- release_resource(r);
- kfree_nocheck(r);
+ release_and_free_resource(r);
return -ENOMEM;
}
gameport_unregister_port(chip->gameport);
chip->gameport = NULL;
- release_resource(r);
- kfree_nocheck(r);
+ release_and_free_resource(r);
}
}
#else
__end_hw:
if (chip->irq >= 0)
free_irq(chip->irq, (void *)chip);
- if (chip->mpu_res) {
- release_resource(chip->mpu_res);
- kfree_nocheck(chip->mpu_res);
- }
+ release_and_free_resource(chip->mpu_res);
pci_release_regions(chip->pci);
if (chip->chip_type == TYPE_VIA686) {
chip->gameport = gp = gameport_allocate_port();
if (!gp) {
printk(KERN_ERR "ymfpci: cannot allocate memory for gameport\n");
- release_resource(r);
- kfree_nocheck(r);
+ release_and_free_resource(r);
return -ENOMEM;
}
gameport_unregister_port(chip->gameport);
chip->gameport = NULL;
- release_resource(r);
- kfree_nocheck(r);
+ release_and_free_resource(r);
}
}
#else
old_legacy_ctrl,
&chip)) < 0) {
snd_card_free(card);
- if (mpu_res) {
- release_resource(mpu_res);
- kfree_nocheck(mpu_res);
- }
- if (fm_res) {
- release_resource(fm_res);
- kfree_nocheck(fm_res);
- }
+ release_and_free_resource(mpu_res);
+ release_and_free_resource(fm_res);
return err;
}
chip->fm_res = fm_res;
#ifdef CONFIG_PM
vfree(chip->saved_regs);
#endif
- if (chip->mpu_res) {
- release_resource(chip->mpu_res);
- kfree_nocheck(chip->mpu_res);
- }
- if (chip->fm_res) {
- release_resource(chip->fm_res);
- kfree_nocheck(chip->fm_res);
- }
+ release_and_free_resource(chip->mpu_res);
+ release_and_free_resource(chip->fm_res);
snd_ymfpci_free_gameport(chip);
if (chip->reg_area_virt)
iounmap(chip->reg_area_virt);
if (chip->irq >= 0)
free_irq(chip->irq, (void *)chip);
- if (chip->res_reg_area) {
- release_resource(chip->res_reg_area);
- kfree_nocheck(chip->res_reg_area);
- }
+ release_and_free_resource(chip->res_reg_area);
pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl);
if (runtime->dma_area) {
if (runtime->dma_bytes >= size)
return 0; /* already enough large */
- vfree_nocheck(runtime->dma_area);
+ vfree(runtime->dma_area);
}
- runtime->dma_area = vmalloc_nocheck(size);
+ runtime->dma_area = vmalloc_32(size);
if (! runtime->dma_area)
return -ENOMEM;
runtime->dma_bytes = size;
{
snd_pcm_runtime_t *runtime = subs->runtime;
if (runtime->dma_area) {
- vfree_nocheck(runtime->dma_area);
+ vfree(runtime->dma_area);
runtime->dma_area = NULL;
}
return 0;
if (runtime->dma_area) {
if (runtime->dma_bytes >= size)
return 0; /* already large enough */
- vfree_nocheck(runtime->dma_area);
+ vfree(runtime->dma_area);
}
- runtime->dma_area = vmalloc_nocheck(size);
+ runtime->dma_area = vmalloc(size);
if (! runtime->dma_area)
return -ENOMEM;
runtime->dma_bytes = size;
{
snd_pcm_runtime_t *runtime = subs->runtime;
if (runtime->dma_area) {
- vfree_nocheck(runtime->dma_area);
+ vfree(runtime->dma_area);
runtime->dma_area = NULL;
}
return 0;