aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorJesper Juhl <juhl-lkml@dif.dk>2005-05-30 11:30:32 -0400
committerJaroslav Kysela <perex@suse.cz>2005-06-22 06:27:43 -0400
commit4d572776d4dfa2d5385a2ec3acec3cc059149e13 (patch)
treeb25ff1baa8d106561d9f07045bbfea6ac330c714 /sound
parent6fd8b87f0e1e5de436ba020bd5806fe9ad738269 (diff)
[ALSA] Remove redundant NULL checks before kfree
Timer Midlevel,ALSA sequencer,ALSA<-OSS sequencer,Digigram VX core I2C tea6330t,GUS Library,VIA82xx driver,VIA82xx-modem driver CA0106 driver,CS46xx driver,EMU10K1/EMU10K2 driver,YMFPCI driver Digigram VX Pocket driver,Common EMU synth,USB generic driver,USB USX2Y Checking a pointer for NULL before calling kfree() on it is redundant, kfree() deals with NULL pointers just fine. This patch removes such checks from sound/ This patch also makes another, but closely related, change. It avoids casting pointers about to be kfree()'ed. Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/core/seq/oss/seq_oss_synth.c24
-rw-r--r--sound/core/seq/seq_dummy.c5
-rw-r--r--sound/core/timer.c12
-rw-r--r--sound/drivers/vx/vx_pcm.c12
-rw-r--r--sound/i2c/tea6330t.c3
-rw-r--r--sound/isa/gus/gus_pcm.c3
-rw-r--r--sound/pci/ca0106/ca0106_main.c6
-rw-r--r--sound/pci/cs46xx/cs46xx_lib.c3
-rw-r--r--sound/pci/emu10k1/emu10k1x.c5
-rw-r--r--sound/pci/emu10k1/emupcm.c4
-rw-r--r--sound/pci/via82xx.c6
-rw-r--r--sound/pci/via82xx_modem.c6
-rw-r--r--sound/pci/ymfpci/ymfpci_main.c4
-rw-r--r--sound/pcmcia/vx/vx_entry.c3
-rw-r--r--sound/synth/emux/emux_effect.c6
-rw-r--r--sound/usb/usbaudio.c12
-rw-r--r--sound/usb/usbmixer.c6
-rw-r--r--sound/usb/usx2y/usbusx2yaudio.c6
18 files changed, 39 insertions, 87 deletions
diff --git a/sound/core/seq/oss/seq_oss_synth.c b/sound/core/seq/oss/seq_oss_synth.c
index 638cc148706..1a7736cbf3a 100644
--- a/sound/core/seq/oss/seq_oss_synth.c
+++ b/sound/core/seq/oss/seq_oss_synth.c
@@ -325,14 +325,10 @@ snd_seq_oss_synth_cleanup(seq_oss_devinfo_t *dp)
325 } 325 }
326 snd_use_lock_free(&rec->use_lock); 326 snd_use_lock_free(&rec->use_lock);
327 } 327 }
328 if (info->sysex) { 328 kfree(info->sysex);
329 kfree(info->sysex); 329 info->sysex = NULL;
330 info->sysex = NULL; 330 kfree(info->ch);
331 } 331 info->ch = NULL;
332 if (info->ch) {
333 kfree(info->ch);
334 info->ch = NULL;
335 }
336 } 332 }
337 dp->synth_opened = 0; 333 dp->synth_opened = 0;
338 dp->max_synthdev = 0; 334 dp->max_synthdev = 0;
@@ -418,14 +414,10 @@ snd_seq_oss_synth_reset(seq_oss_devinfo_t *dp, int dev)
418 dp->file_mode) < 0) { 414 dp->file_mode) < 0) {
419 midi_synth_dev.opened--; 415 midi_synth_dev.opened--;
420 info->opened = 0; 416 info->opened = 0;
421 if (info->sysex) { 417 kfree(info->sysex);
422 kfree(info->sysex); 418 info->sysex = NULL;
423 info->sysex = NULL; 419 kfree(info->ch);
424 } 420 info->ch = NULL;
425 if (info->ch) {
426 kfree(info->ch);
427 info->ch = NULL;
428 }
429 } 421 }
430 return; 422 return;
431 } 423 }
diff --git a/sound/core/seq/seq_dummy.c b/sound/core/seq/seq_dummy.c
index e88967c5b93..ea945a5d2a0 100644
--- a/sound/core/seq/seq_dummy.c
+++ b/sound/core/seq/seq_dummy.c
@@ -140,10 +140,7 @@ dummy_input(snd_seq_event_t *ev, int direct, void *private_data, int atomic, int
140static void 140static void
141dummy_free(void *private_data) 141dummy_free(void *private_data)
142{ 142{
143 snd_seq_dummy_port_t *p; 143 kfree(private_data);
144
145 p = private_data;
146 kfree(p);
147} 144}
148 145
149/* 146/*
diff --git a/sound/core/timer.c b/sound/core/timer.c
index d67a5e91a10..b498e5482d7 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -1469,14 +1469,10 @@ static int snd_timer_user_tselect(struct file *file, snd_timer_select_t __user *
1469 if ((err = snd_timer_open(&tu->timeri, str, &tselect.id, current->pid)) < 0) 1469 if ((err = snd_timer_open(&tu->timeri, str, &tselect.id, current->pid)) < 0)
1470 goto __err; 1470 goto __err;
1471 1471
1472 if (tu->queue) { 1472 kfree(tu->queue);
1473 kfree(tu->queue); 1473 tu->queue = NULL;
1474 tu->queue = NULL; 1474 kfree(tu->tqueue);
1475 } 1475 tu->tqueue = NULL;
1476 if (tu->tqueue) {
1477 kfree(tu->tqueue);
1478 tu->tqueue = NULL;
1479 }
1480 if (tu->tread) { 1476 if (tu->tread) {
1481 tu->tqueue = (snd_timer_tread_t *)kmalloc(tu->queue_size * sizeof(snd_timer_tread_t), GFP_KERNEL); 1477 tu->tqueue = (snd_timer_tread_t *)kmalloc(tu->queue_size * sizeof(snd_timer_tread_t), GFP_KERNEL);
1482 if (tu->tqueue == NULL) 1478 if (tu->tqueue == NULL)
diff --git a/sound/drivers/vx/vx_pcm.c b/sound/drivers/vx/vx_pcm.c
index 98587176b32..af381b15fe5 100644
--- a/sound/drivers/vx/vx_pcm.c
+++ b/sound/drivers/vx/vx_pcm.c
@@ -1264,14 +1264,10 @@ static void snd_vx_pcm_free(snd_pcm_t *pcm)
1264{ 1264{
1265 vx_core_t *chip = pcm->private_data; 1265 vx_core_t *chip = pcm->private_data;
1266 chip->pcm[pcm->device] = NULL; 1266 chip->pcm[pcm->device] = NULL;
1267 if (chip->playback_pipes) { 1267 kfree(chip->playback_pipes);
1268 kfree(chip->playback_pipes); 1268 chip->playback_pipes = NULL;
1269 chip->playback_pipes = NULL; 1269 kfree(chip->capture_pipes);
1270 } 1270 chip->capture_pipes = NULL;
1271 if (chip->capture_pipes) {
1272 kfree(chip->capture_pipes);
1273 chip->capture_pipes = NULL;
1274 }
1275} 1271}
1276 1272
1277/* 1273/*
diff --git a/sound/i2c/tea6330t.c b/sound/i2c/tea6330t.c
index bb503e70b66..2da8d7f157f 100644
--- a/sound/i2c/tea6330t.c
+++ b/sound/i2c/tea6330t.c
@@ -266,8 +266,7 @@ TEA6330T_TREBLE("Tone Control - Treble", 0)
266 266
267static void snd_tea6330_free(snd_i2c_device_t *device) 267static void snd_tea6330_free(snd_i2c_device_t *device)
268{ 268{
269 tea6330t_t *tea = device->private_data; 269 kfree(device->private_data);
270 kfree(tea);
271} 270}
272 271
273int snd_tea6330t_update_mixer(snd_card_t * card, 272int snd_tea6330t_update_mixer(snd_card_t * card,
diff --git a/sound/isa/gus/gus_pcm.c b/sound/isa/gus/gus_pcm.c
index 8995ad9c516..b75066ab46f 100644
--- a/sound/isa/gus/gus_pcm.c
+++ b/sound/isa/gus/gus_pcm.c
@@ -656,8 +656,7 @@ static snd_pcm_hardware_t snd_gf1_pcm_capture =
656 656
657static void snd_gf1_pcm_playback_free(snd_pcm_runtime_t *runtime) 657static void snd_gf1_pcm_playback_free(snd_pcm_runtime_t *runtime)
658{ 658{
659 gus_pcm_private_t * pcmp = runtime->private_data; 659 kfree(runtime->private_data);
660 kfree(pcmp);
661} 660}
662 661
663static int snd_gf1_pcm_playback_open(snd_pcm_substream_t *substream) 662static int snd_gf1_pcm_playback_open(snd_pcm_substream_t *substream)
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index 85caf1bbcc1..0ec0c3ec220 100644
--- a/sound/pci/ca0106/ca0106_main.c
+++ b/sound/pci/ca0106/ca0106_main.c
@@ -332,11 +332,7 @@ static void snd_ca0106_intr_enable(ca0106_t *emu, unsigned int intrenb)
332 332
333static void snd_ca0106_pcm_free_substream(snd_pcm_runtime_t *runtime) 333static void snd_ca0106_pcm_free_substream(snd_pcm_runtime_t *runtime)
334{ 334{
335 ca0106_pcm_t *epcm = runtime->private_data; 335 kfree(runtime->private_data);
336
337 if (epcm) {
338 kfree(epcm);
339 }
340} 336}
341 337
342/* open_playback callback */ 338/* open_playback callback */
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index 5f2ffb7efa0..fd4c50c88bc 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -1295,8 +1295,7 @@ static snd_pcm_hw_constraint_list_t hw_constraints_period_sizes = {
1295 1295
1296static void snd_cs46xx_pcm_free_substream(snd_pcm_runtime_t *runtime) 1296static void snd_cs46xx_pcm_free_substream(snd_pcm_runtime_t *runtime)
1297{ 1297{
1298 cs46xx_pcm_t * cpcm = runtime->private_data; 1298 kfree(runtime->private_data);
1299 kfree(cpcm);
1300} 1299}
1301 1300
1302static int _cs46xx_playback_open_channel (snd_pcm_substream_t * substream,int pcm_channel_id) 1301static int _cs46xx_playback_open_channel (snd_pcm_substream_t * substream,int pcm_channel_id)
diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c
index f8d92335a35..e90c5ddd1d1 100644
--- a/sound/pci/emu10k1/emu10k1x.c
+++ b/sound/pci/emu10k1/emu10k1x.c
@@ -361,10 +361,7 @@ static void snd_emu10k1x_gpio_write(emu10k1x_t *emu, unsigned int value)
361 361
362static void snd_emu10k1x_pcm_free_substream(snd_pcm_runtime_t *runtime) 362static void snd_emu10k1x_pcm_free_substream(snd_pcm_runtime_t *runtime)
363{ 363{
364 emu10k1x_pcm_t *epcm = runtime->private_data; 364 kfree(runtime->private_data);
365
366 if (epcm)
367 kfree(epcm);
368} 365}
369 366
370static void snd_emu10k1x_pcm_interrupt(emu10k1x_t *emu, emu10k1x_voice_t *voice) 367static void snd_emu10k1x_pcm_interrupt(emu10k1x_t *emu, emu10k1x_voice_t *voice)
diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c
index fd7cc389f82..520b99af5f5 100644
--- a/sound/pci/emu10k1/emupcm.c
+++ b/sound/pci/emu10k1/emupcm.c
@@ -991,9 +991,7 @@ static void snd_emu10k1_pcm_efx_mixer_notify(emu10k1_t *emu, int idx, int activa
991 991
992static void snd_emu10k1_pcm_free_substream(snd_pcm_runtime_t *runtime) 992static void snd_emu10k1_pcm_free_substream(snd_pcm_runtime_t *runtime)
993{ 993{
994 emu10k1_pcm_t *epcm = runtime->private_data; 994 kfree(runtime->private_data);
995
996 kfree(epcm);
997} 995}
998 996
999static int snd_emu10k1_efx_playback_close(snd_pcm_substream_t * substream) 997static int snd_emu10k1_efx_playback_close(snd_pcm_substream_t * substream)
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index 52d1074f869..e329e19b674 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -491,10 +491,8 @@ static int clean_via_table(viadev_t *dev, snd_pcm_substream_t *substream,
491 snd_dma_free_pages(&dev->table); 491 snd_dma_free_pages(&dev->table);
492 dev->table.area = NULL; 492 dev->table.area = NULL;
493 } 493 }
494 if (dev->idx_table) { 494 kfree(dev->idx_table);
495 kfree(dev->idx_table); 495 dev->idx_table = NULL;
496 dev->idx_table = NULL;
497 }
498 return 0; 496 return 0;
499} 497}
500 498
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c
index e10fceb3ede..5896d289f9a 100644
--- a/sound/pci/via82xx_modem.c
+++ b/sound/pci/via82xx_modem.c
@@ -352,10 +352,8 @@ static int clean_via_table(viadev_t *dev, snd_pcm_substream_t *substream,
352 snd_dma_free_pages(&dev->table); 352 snd_dma_free_pages(&dev->table);
353 dev->table.area = NULL; 353 dev->table.area = NULL;
354 } 354 }
355 if (dev->idx_table) { 355 kfree(dev->idx_table);
356 kfree(dev->idx_table); 356 dev->idx_table = NULL;
357 dev->idx_table = NULL;
358 }
359 return 0; 357 return 0;
360} 358}
361 359
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
index 997cf37cddd..2ae79610ecb 100644
--- a/sound/pci/ymfpci/ymfpci_main.c
+++ b/sound/pci/ymfpci/ymfpci_main.c
@@ -829,9 +829,7 @@ static snd_pcm_hardware_t snd_ymfpci_capture =
829 829
830static void snd_ymfpci_pcm_free_substream(snd_pcm_runtime_t *runtime) 830static void snd_ymfpci_pcm_free_substream(snd_pcm_runtime_t *runtime)
831{ 831{
832 ymfpci_pcm_t *ypcm = runtime->private_data; 832 kfree(runtime->private_data);
833
834 kfree(ypcm);
835} 833}
836 834
837static int snd_ymfpci_playback_open_1(snd_pcm_substream_t * substream) 835static int snd_ymfpci_playback_open_1(snd_pcm_substream_t * substream)
diff --git a/sound/pcmcia/vx/vx_entry.c b/sound/pcmcia/vx/vx_entry.c
index 53d8172c52a..332bbca3dfc 100644
--- a/sound/pcmcia/vx/vx_entry.c
+++ b/sound/pcmcia/vx/vx_entry.c
@@ -68,8 +68,7 @@ static int snd_vxpocket_free(vx_core_t *chip)
68 if (hw) 68 if (hw)
69 hw->card_list[vxp->index] = NULL; 69 hw->card_list[vxp->index] = NULL;
70 chip->card = NULL; 70 chip->card = NULL;
71 if (chip->dev) 71 kfree(chip->dev);
72 kfree(chip->dev);
73 72
74 snd_vx_free_firmware(chip); 73 snd_vx_free_firmware(chip);
75 kfree(chip); 74 kfree(chip);
diff --git a/sound/synth/emux/emux_effect.c b/sound/synth/emux/emux_effect.c
index ec3fc1ba7fc..4764940f11a 100644
--- a/sound/synth/emux/emux_effect.c
+++ b/sound/synth/emux/emux_effect.c
@@ -291,10 +291,8 @@ snd_emux_create_effect(snd_emux_port_t *p)
291void 291void
292snd_emux_delete_effect(snd_emux_port_t *p) 292snd_emux_delete_effect(snd_emux_port_t *p)
293{ 293{
294 if (p->effect) { 294 kfree(p->effect);
295 kfree(p->effect); 295 p->effect = NULL;
296 p->effect = NULL;
297 }
298} 296}
299 297
300void 298void
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index a82412b8790..a75695045f2 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -859,10 +859,8 @@ static void release_urb_ctx(snd_urb_ctx_t *u)
859 usb_free_urb(u->urb); 859 usb_free_urb(u->urb);
860 u->urb = NULL; 860 u->urb = NULL;
861 } 861 }
862 if (u->buf) { 862 kfree(u->buf);
863 kfree(u->buf); 863 u->buf = NULL;
864 u->buf = NULL;
865 }
866} 864}
867 865
868/* 866/*
@@ -880,10 +878,8 @@ static void release_substream_urbs(snd_usb_substream_t *subs, int force)
880 release_urb_ctx(&subs->dataurb[i]); 878 release_urb_ctx(&subs->dataurb[i]);
881 for (i = 0; i < SYNC_URBS; i++) 879 for (i = 0; i < SYNC_URBS; i++)
882 release_urb_ctx(&subs->syncurb[i]); 880 release_urb_ctx(&subs->syncurb[i]);
883 if (subs->tmpbuf) { 881 kfree(subs->tmpbuf);
884 kfree(subs->tmpbuf); 882 subs->tmpbuf = NULL;
885 subs->tmpbuf = NULL;
886 }
887 subs->nurbs = 0; 883 subs->nurbs = 0;
888} 884}
889 885
diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c
index 83ba665e5c6..e73c1c9d3e7 100644
--- a/sound/usb/usbmixer.c
+++ b/sound/usb/usbmixer.c
@@ -623,10 +623,8 @@ static struct usb_feature_control_info audio_feature_info[] = {
623/* private_free callback */ 623/* private_free callback */
624static void usb_mixer_elem_free(snd_kcontrol_t *kctl) 624static void usb_mixer_elem_free(snd_kcontrol_t *kctl)
625{ 625{
626 if (kctl->private_data) { 626 kfree(kctl->private_data);
627 kfree(kctl->private_data); 627 kctl->private_data = NULL;
628 kctl->private_data = NULL;
629 }
630} 628}
631 629
632 630
diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c
index 4c292e09006..62dfd28b3b0 100644
--- a/sound/usb/usx2y/usbusx2yaudio.c
+++ b/sound/usb/usx2y/usbusx2yaudio.c
@@ -401,10 +401,8 @@ static void usX2Y_urbs_release(snd_usX2Y_substream_t *subs)
401 for (i = 0; i < NRURBS; i++) 401 for (i = 0; i < NRURBS; i++)
402 usX2Y_urb_release(subs->urb + i, subs != subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]); 402 usX2Y_urb_release(subs->urb + i, subs != subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]);
403 403
404 if (subs->tmpbuf) { 404 kfree(subs->tmpbuf);
405 kfree(subs->tmpbuf); 405 subs->tmpbuf = NULL;
406 subs->tmpbuf = NULL;
407 }
408} 406}
409/* 407/*
410 * initialize a substream's urbs 408 * initialize a substream's urbs