summaryrefslogtreecommitdiff
path: root/sound/pci/emu10k1/emufx.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/emu10k1/emufx.c')
-rw-r--r--sound/pci/emu10k1/emufx.c76
1 files changed, 31 insertions, 45 deletions
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
index 1f9c7c4..0275209 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -1182,20 +1182,15 @@ static int _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu)
u32 *gpr_map;
mm_segment_t seg;
- err = -ENOMEM;
- icode = kzalloc(sizeof(*icode), GFP_KERNEL);
- if (!icode)
- return err;
-
- icode->gpr_map = (u_int32_t __user *) kcalloc(512 + 256 + 256 + 2 * 1024,
- sizeof(u_int32_t), GFP_KERNEL);
- if (!icode->gpr_map)
- goto __err_gpr;
- controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
- sizeof(*controls), GFP_KERNEL);
- if (!controls)
- goto __err_ctrls;
-
+ if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL ||
+ (icode->gpr_map = (u_int32_t __user *)
+ kcalloc(512 + 256 + 256 + 2 * 1024, sizeof(u_int32_t),
+ GFP_KERNEL)) == NULL ||
+ (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
+ sizeof(*controls), GFP_KERNEL)) == NULL) {
+ err = -ENOMEM;
+ goto __err;
+ }
gpr_map = (u32 __force *)icode->gpr_map;
icode->tram_data_map = icode->gpr_map + 512;
@@ -1746,12 +1741,12 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
emu->support_tlv = 0; /* clear again */
snd_leave_user(seg);
-__err:
+ __err:
kfree(controls);
-__err_ctrls:
- kfree((void __force *)icode->gpr_map);
-__err_gpr:
- kfree(icode);
+ if (icode != NULL) {
+ kfree((void __force *)icode->gpr_map);
+ kfree(icode);
+ }
return err;
}
@@ -1818,26 +1813,18 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu)
u32 *gpr_map;
mm_segment_t seg;
- err = -ENOMEM;
- icode = kzalloc(sizeof(*icode), GFP_KERNEL);
- if (!icode)
- return err;
-
- icode->gpr_map = (u_int32_t __user *) kcalloc(256 + 160 + 160 + 2 * 512,
- sizeof(u_int32_t), GFP_KERNEL);
- if (!icode->gpr_map)
- goto __err_gpr;
-
- controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
- sizeof(struct snd_emu10k1_fx8010_control_gpr),
- GFP_KERNEL);
- if (!controls)
- goto __err_ctrls;
-
- ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL);
- if (!ipcm)
- goto __err_ipcm;
-
+ if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL)
+ return -ENOMEM;
+ if ((icode->gpr_map = (u_int32_t __user *)
+ kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t),
+ GFP_KERNEL)) == NULL ||
+ (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
+ sizeof(struct snd_emu10k1_fx8010_control_gpr),
+ GFP_KERNEL)) == NULL ||
+ (ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL)) == NULL) {
+ err = -ENOMEM;
+ goto __err;
+ }
gpr_map = (u32 __force *)icode->gpr_map;
icode->tram_data_map = icode->gpr_map + 256;
@@ -2376,14 +2363,13 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu)
snd_leave_user(seg);
if (err >= 0)
err = snd_emu10k1_ipcm_poke(emu, ipcm);
-__err:
+ __err:
kfree(ipcm);
-__err_ipcm:
kfree(controls);
-__err_ctrls:
- kfree((void __force *)icode->gpr_map);
-__err_gpr:
- kfree(icode);
+ if (icode != NULL) {
+ kfree((void __force *)icode->gpr_map);
+ kfree(icode);
+ }
return err;
}