From 62932df8fb20ba2fb53a95fa52445eba22e821fe Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Mon, 16 Jan 2006 16:34:20 +0100 Subject: [ALSA] semaphore -> mutex (PCI part) Semaphore to mutex conversion. The conversion was generated via scripts, and the result was validated automatically via a script as well. Signed-off-by: Ingo Molnar Signed-off-by: Andrew Morton Signed-off-by: Takashi Iwai --- sound/pci/cs46xx/dsp_spos.c | 58 +++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 28 deletions(-) (limited to 'sound/pci/cs46xx/dsp_spos.c') diff --git a/sound/pci/cs46xx/dsp_spos.c b/sound/pci/cs46xx/dsp_spos.c index 445a448949e..8726a68051e 100644 --- a/sound/pci/cs46xx/dsp_spos.c +++ b/sound/pci/cs46xx/dsp_spos.c @@ -28,6 +28,8 @@ #include #include #include +#include + #include #include #include @@ -287,7 +289,7 @@ void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip) snd_assert(ins != NULL, return); - down(&chip->spos_mutex); + mutex_lock(&chip->spos_mutex); for (i = 0; i < ins->nscb; ++i) { if (ins->scbs[i].deleted) continue; @@ -298,7 +300,7 @@ void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip) vfree(ins->symbol_table.symbols); kfree(ins->modules); kfree(ins); - up(&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); } int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * module) @@ -497,7 +499,7 @@ static void cs46xx_dsp_proc_modules_read (struct snd_info_entry *entry, struct dsp_spos_instance * ins = chip->dsp_spos_instance; int i,j; - down(&chip->spos_mutex); + mutex_lock(&chip->spos_mutex); snd_iprintf(buffer, "MODULES:\n"); for ( i = 0; i < ins->nmodules; ++i ) { snd_iprintf(buffer, "\n%s:\n", ins->modules[i].module_name); @@ -510,7 +512,7 @@ static void cs46xx_dsp_proc_modules_read (struct snd_info_entry *entry, desc->segment_type,desc->offset, desc->size); } } - up(&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); } static void cs46xx_dsp_proc_task_tree_read (struct snd_info_entry *entry, @@ -521,7 +523,7 @@ static void cs46xx_dsp_proc_task_tree_read (struct snd_info_entry *entry, int i, j, col; void __iomem *dst = chip->region.idx[1].remap_addr + DSP_PARAMETER_BYTE_OFFSET; - down(&chip->spos_mutex); + mutex_lock(&chip->spos_mutex); snd_iprintf(buffer, "TASK TREES:\n"); for ( i = 0; i < ins->ntask; ++i) { snd_iprintf(buffer,"\n%04x %s:\n",ins->tasks[i].address,ins->tasks[i].task_name); @@ -538,7 +540,7 @@ static void cs46xx_dsp_proc_task_tree_read (struct snd_info_entry *entry, } snd_iprintf(buffer,"\n"); - up(&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); } static void cs46xx_dsp_proc_scb_read (struct snd_info_entry *entry, @@ -548,7 +550,7 @@ static void cs46xx_dsp_proc_scb_read (struct snd_info_entry *entry, struct dsp_spos_instance * ins = chip->dsp_spos_instance; int i; - down(&chip->spos_mutex); + mutex_lock(&chip->spos_mutex); snd_iprintf(buffer, "SCB's:\n"); for ( i = 0; i < ins->nscb; ++i) { if (ins->scbs[i].deleted) @@ -571,7 +573,7 @@ static void cs46xx_dsp_proc_scb_read (struct snd_info_entry *entry, } snd_iprintf(buffer,"\n"); - up(&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); } static void cs46xx_dsp_proc_parameter_dump_read (struct snd_info_entry *entry, @@ -852,14 +854,14 @@ int cs46xx_dsp_proc_init (struct snd_card *card, struct snd_cs46xx *chip) } ins->proc_scb_info_entry = entry; - down(&chip->spos_mutex); + mutex_lock(&chip->spos_mutex); /* register/update SCB's entries on proc */ for (i = 0; i < ins->nscb; ++i) { if (ins->scbs[i].deleted) continue; cs46xx_dsp_proc_register_scb_desc (chip, (ins->scbs + i)); } - up(&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); return 0; } @@ -899,12 +901,12 @@ int cs46xx_dsp_proc_done (struct snd_cs46xx *chip) ins->proc_task_info_entry = NULL; } - down(&chip->spos_mutex); + mutex_lock(&chip->spos_mutex); for (i = 0; i < ins->nscb; ++i) { if (ins->scbs[i].deleted) continue; cs46xx_dsp_proc_free_scb_desc ( (ins->scbs + i) ); } - up(&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); if (ins->proc_dsp_dir) { snd_info_unregister (ins->proc_dsp_dir); @@ -1694,7 +1696,7 @@ int cs46xx_dsp_enable_spdif_in (struct snd_cs46xx *chip) snd_assert (ins->asynch_rx_scb == NULL,return -EINVAL); snd_assert (ins->spdif_in_src != NULL,return -EINVAL); - down(&chip->spos_mutex); + mutex_lock(&chip->spos_mutex); if ( ! (ins->spdif_status_out & DSP_SPDIF_STATUS_INPUT_CTRL_ENABLED) ) { /* time countdown enable */ @@ -1738,7 +1740,7 @@ int cs46xx_dsp_enable_spdif_in (struct snd_cs46xx *chip) /* monitor state */ ins->spdif_status_in = 1; - up(&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); return 0; } @@ -1750,7 +1752,7 @@ int cs46xx_dsp_disable_spdif_in (struct snd_cs46xx *chip) snd_assert (ins->asynch_rx_scb != NULL, return -EINVAL); snd_assert (ins->spdif_in_src != NULL,return -EINVAL); - down(&chip->spos_mutex); + mutex_lock(&chip->spos_mutex); /* Remove the asynchronous receiver SCB */ cs46xx_dsp_remove_scb (chip,ins->asynch_rx_scb); @@ -1760,7 +1762,7 @@ int cs46xx_dsp_disable_spdif_in (struct snd_cs46xx *chip) /* monitor state */ ins->spdif_status_in = 0; - up(&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); /* restore amplifier */ chip->active_ctrl(chip, -1); @@ -1776,10 +1778,10 @@ int cs46xx_dsp_enable_pcm_capture (struct snd_cs46xx *chip) snd_assert (ins->pcm_input == NULL,return -EINVAL); snd_assert (ins->ref_snoop_scb != NULL,return -EINVAL); - down(&chip->spos_mutex); + mutex_lock(&chip->spos_mutex); ins->pcm_input = cs46xx_add_record_source(chip,ins->ref_snoop_scb,PCMSERIALIN_PCM_SCB_ADDR, "PCMSerialInput_Wave"); - up(&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); return 0; } @@ -1790,10 +1792,10 @@ int cs46xx_dsp_disable_pcm_capture (struct snd_cs46xx *chip) snd_assert (ins->pcm_input != NULL,return -EINVAL); - down(&chip->spos_mutex); + mutex_lock(&chip->spos_mutex); cs46xx_dsp_remove_scb (chip,ins->pcm_input); ins->pcm_input = NULL; - up(&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); return 0; } @@ -1805,10 +1807,10 @@ int cs46xx_dsp_enable_adc_capture (struct snd_cs46xx *chip) snd_assert (ins->adc_input == NULL,return -EINVAL); snd_assert (ins->codec_in_scb != NULL,return -EINVAL); - down(&chip->spos_mutex); + mutex_lock(&chip->spos_mutex); ins->adc_input = cs46xx_add_record_source(chip,ins->codec_in_scb,PCMSERIALIN_SCB_ADDR, "PCMSerialInput_ADC"); - up(&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); return 0; } @@ -1819,10 +1821,10 @@ int cs46xx_dsp_disable_adc_capture (struct snd_cs46xx *chip) snd_assert (ins->adc_input != NULL,return -EINVAL); - down(&chip->spos_mutex); + mutex_lock(&chip->spos_mutex); cs46xx_dsp_remove_scb (chip,ins->adc_input); ins->adc_input = NULL; - up(&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); return 0; } @@ -1869,7 +1871,7 @@ int cs46xx_dsp_set_dac_volume (struct snd_cs46xx * chip, u16 left, u16 right) struct dsp_spos_instance * ins = chip->dsp_spos_instance; struct dsp_scb_descriptor * scb; - down(&chip->spos_mutex); + mutex_lock(&chip->spos_mutex); /* main output */ scb = ins->master_mix_scb->sub_list_ptr; @@ -1888,7 +1890,7 @@ int cs46xx_dsp_set_dac_volume (struct snd_cs46xx * chip, u16 left, u16 right) ins->dac_volume_left = left; ins->dac_volume_right = right; - up(&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); return 0; } @@ -1897,7 +1899,7 @@ int cs46xx_dsp_set_iec958_volume (struct snd_cs46xx * chip, u16 left, u16 right) { struct dsp_spos_instance * ins = chip->dsp_spos_instance; - down(&chip->spos_mutex); + mutex_lock(&chip->spos_mutex); if (ins->asynch_rx_scb != NULL) cs46xx_dsp_scb_set_volume (chip,ins->asynch_rx_scb, @@ -1906,7 +1908,7 @@ int cs46xx_dsp_set_iec958_volume (struct snd_cs46xx * chip, u16 left, u16 right) ins->spdif_input_volume_left = left; ins->spdif_input_volume_right = right; - up(&chip->spos_mutex); + mutex_unlock(&chip->spos_mutex); return 0; } -- cgit v1.2.3-70-g09d2 From 202728d783a0fc180e7141d18186eeae167218a1 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 14 Mar 2006 09:44:19 +0100 Subject: [ALSA] fix some memory leaks Modules: Generic drivers,ES18xx driver,CS46xx driver This patch fixes two memory leaks spotted by the Coverity checker. Signed-off-by: Adrian Bunk Signed-off-by: Takashi Iwai --- sound/drivers/serial-u16550.c | 1 + sound/isa/es18xx.c | 1 + sound/pci/cs46xx/dsp_spos.c | 10 +++++++--- 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'sound/pci/cs46xx/dsp_spos.c') diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c index 13b46d12564..1a7fbefe474 100644 --- a/sound/drivers/serial-u16550.c +++ b/sound/drivers/serial-u16550.c @@ -789,6 +789,7 @@ static int __init snd_uart16550_create(struct snd_card *card, if ((err = snd_uart16550_detect(uart)) <= 0) { printk(KERN_ERR "no UART detected at 0x%lx\n", iobase); + snd_uart16550_free(uart); return -ENODEV; } diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index bb709264216..721955d2619 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c @@ -2083,6 +2083,7 @@ static int __devinit snd_audiodrive_pnp(int dev, struct snd_audiodrive *acard, err = pnp_activate_dev(acard->devc); if (err < 0) { snd_printk(KERN_ERR PFX "PnP control configure failure (out of resources?)\n"); + kfree(cfg); return -EAGAIN; } snd_printdd("pnp: port=0x%lx\n", pnp_port_start(acard->devc, 0)); diff --git a/sound/pci/cs46xx/dsp_spos.c b/sound/pci/cs46xx/dsp_spos.c index 8726a68051e..f407d2a5ce3 100644 --- a/sound/pci/cs46xx/dsp_spos.c +++ b/sound/pci/cs46xx/dsp_spos.c @@ -237,7 +237,7 @@ struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip) if (ins->symbol_table.symbols == NULL) { cs46xx_dsp_spos_destroy(chip); - return NULL; + goto error; } ins->code.offset = 0; @@ -246,7 +246,7 @@ struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip) if (ins->code.data == NULL) { cs46xx_dsp_spos_destroy(chip); - return NULL; + goto error; } ins->nscb = 0; @@ -257,7 +257,7 @@ struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip) if (ins->modules == NULL) { cs46xx_dsp_spos_destroy(chip); - return NULL; + goto error; } /* default SPDIF input sample rate @@ -280,6 +280,10 @@ struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip) /* left and right validity bits */ (1 << 13) | (1 << 12); return ins; + +error: + kfree(ins); + return NULL; } void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip) -- cgit v1.2.3-70-g09d2