aboutsummaryrefslogtreecommitdiffstats
path: root/sound/oss
diff options
context:
space:
mode:
authorJesper Juhl <juhl-lkml@dif.dk>2005-06-25 17:58:49 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-25 19:25:00 -0400
commit09417379be9b126e10ae7dcd7afc20b666146266 (patch)
tree0236f4cb1afb4cf9a7f13b67e6ac639c55fa0440 /sound/oss
parent4ae6673e029d609da7ef4311440d6de501d6967a (diff)
[PATCH] remove redundant NULL checks before kfree() in sound/ and avoid casting pointers about to be kfree()'ed
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: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'sound/oss')
-rw-r--r--sound/oss/ad1848.c3
-rw-r--r--sound/oss/ad1889.c3
-rw-r--r--sound/oss/dmasound/dmasound_awacs.c20
-rw-r--r--sound/oss/emu10k1/midi.c6
-rw-r--r--sound/oss/emu10k1/passthrough.c3
-rw-r--r--sound/oss/maestro.c2
-rw-r--r--sound/oss/mpu401.c3
-rw-r--r--sound/oss/sb_common.c4
8 files changed, 16 insertions, 28 deletions
diff --git a/sound/oss/ad1848.c b/sound/oss/ad1848.c
index 4384dac3f794..7c835abd99bc 100644
--- a/sound/oss/ad1848.c
+++ b/sound/oss/ad1848.c
@@ -2178,8 +2178,7 @@ void ad1848_unload(int io_base, int irq, int dma_playback, int dma_capture, int
2178 2178
2179 if (devc != NULL) 2179 if (devc != NULL)
2180 { 2180 {
2181 if(audio_devs[dev]->portc!=NULL) 2181 kfree(audio_devs[dev]->portc);
2182 kfree(audio_devs[dev]->portc);
2183 release_region(devc->base, 4); 2182 release_region(devc->base, 4);
2184 2183
2185 if (!share_dma) 2184 if (!share_dma)
diff --git a/sound/oss/ad1889.c b/sound/oss/ad1889.c
index b767c621fd09..2cfd214e4c2a 100644
--- a/sound/oss/ad1889.c
+++ b/sound/oss/ad1889.c
@@ -277,8 +277,7 @@ static void ad1889_free_dev(ad1889_dev_t *dev)
277 277
278 for (j = 0; j < AD_MAX_STATES; j++) { 278 for (j = 0; j < AD_MAX_STATES; j++) {
279 dmabuf = &dev->state[j].dmabuf; 279 dmabuf = &dev->state[j].dmabuf;
280 if (dmabuf->rawbuf != NULL) 280 kfree(dmabuf->rawbuf);
281 kfree(dmabuf->rawbuf);
282 } 281 }
283 282
284 kfree(dev); 283 kfree(dev);
diff --git a/sound/oss/dmasound/dmasound_awacs.c b/sound/oss/dmasound/dmasound_awacs.c
index 5281b88987f3..33108661e671 100644
--- a/sound/oss/dmasound/dmasound_awacs.c
+++ b/sound/oss/dmasound/dmasound_awacs.c
@@ -671,14 +671,10 @@ static void PMacIrqCleanup(void)
671 release_OF_resource(awacs_node, 1); 671 release_OF_resource(awacs_node, 1);
672 release_OF_resource(awacs_node, 2); 672 release_OF_resource(awacs_node, 2);
673 673
674 if (awacs_tx_cmd_space) 674 kfree(awacs_tx_cmd_space);
675 kfree(awacs_tx_cmd_space); 675 kfree(awacs_rx_cmd_space);
676 if (awacs_rx_cmd_space) 676 kfree(beep_dbdma_cmd_space);
677 kfree(awacs_rx_cmd_space); 677 kfree(beep_buf);
678 if (beep_dbdma_cmd_space)
679 kfree(beep_dbdma_cmd_space);
680 if (beep_buf)
681 kfree(beep_buf);
682#ifdef CONFIG_PMAC_PBOOK 678#ifdef CONFIG_PMAC_PBOOK
683 pmu_unregister_sleep_notifier(&awacs_sleep_notifier); 679 pmu_unregister_sleep_notifier(&awacs_sleep_notifier);
684#endif 680#endif
@@ -2301,8 +2297,7 @@ if (count <= 0)
2301#endif 2297#endif
2302 2298
2303 if ((write_sq.max_count + 1) > number_of_tx_cmd_buffers) { 2299 if ((write_sq.max_count + 1) > number_of_tx_cmd_buffers) {
2304 if (awacs_tx_cmd_space) 2300 kfree(awacs_tx_cmd_space);
2305 kfree(awacs_tx_cmd_space);
2306 number_of_tx_cmd_buffers = 0; 2301 number_of_tx_cmd_buffers = 0;
2307 2302
2308 /* we need nbufs + 1 (for the loop) and we should request + 1 2303 /* we need nbufs + 1 (for the loop) and we should request + 1
@@ -2360,8 +2355,7 @@ if (count <= 0)
2360#endif 2355#endif
2361 2356
2362 if ((read_sq.max_count+1) > number_of_rx_cmd_buffers ) { 2357 if ((read_sq.max_count+1) > number_of_rx_cmd_buffers ) {
2363 if (awacs_rx_cmd_space) 2358 kfree(awacs_rx_cmd_space);
2364 kfree(awacs_rx_cmd_space);
2365 number_of_rx_cmd_buffers = 0; 2359 number_of_rx_cmd_buffers = 0;
2366 2360
2367 /* we need nbufs + 1 (for the loop) and we should request + 1 again 2361 /* we need nbufs + 1 (for the loop) and we should request + 1 again
@@ -2805,7 +2799,7 @@ __init setup_beep(void)
2805 beep_buf = (short *) kmalloc(BEEP_BUFLEN * 4, GFP_KERNEL); 2799 beep_buf = (short *) kmalloc(BEEP_BUFLEN * 4, GFP_KERNEL);
2806 if (beep_buf == NULL) { 2800 if (beep_buf == NULL) {
2807 printk(KERN_ERR "dmasound_pmac: no memory for beep buffer\n"); 2801 printk(KERN_ERR "dmasound_pmac: no memory for beep buffer\n");
2808 if( beep_dbdma_cmd_space ) kfree(beep_dbdma_cmd_space) ; 2802 kfree(beep_dbdma_cmd_space) ;
2809 return -ENOMEM ; 2803 return -ENOMEM ;
2810 } 2804 }
2811 return 0 ; 2805 return 0 ;
diff --git a/sound/oss/emu10k1/midi.c b/sound/oss/emu10k1/midi.c
index 33dea3d56c1e..b40b5f97aace 100644
--- a/sound/oss/emu10k1/midi.c
+++ b/sound/oss/emu10k1/midi.c
@@ -523,10 +523,8 @@ void emu10k1_seq_midi_close(int dev)
523 card = midi_devs[dev]->devc; 523 card = midi_devs[dev]->devc;
524 emu10k1_mpuout_close(card); 524 emu10k1_mpuout_close(card);
525 525
526 if (card->seq_mididev) { 526 kfree(card->seq_mididev);
527 kfree(card->seq_mididev); 527 card->seq_mididev = NULL;
528 card->seq_mididev = NULL;
529 }
530} 528}
531 529
532int emu10k1_seq_midi_out(int dev, unsigned char midi_byte) 530int emu10k1_seq_midi_out(int dev, unsigned char midi_byte)
diff --git a/sound/oss/emu10k1/passthrough.c b/sound/oss/emu10k1/passthrough.c
index 4094be55f3be..4e3baca7d41f 100644
--- a/sound/oss/emu10k1/passthrough.c
+++ b/sound/oss/emu10k1/passthrough.c
@@ -213,8 +213,7 @@ void emu10k1_pt_stop(struct emu10k1_card *card)
213 sblive_writeptr(card, SPCS0 + i, 0, pt->old_spcs[i]); 213 sblive_writeptr(card, SPCS0 + i, 0, pt->old_spcs[i]);
214 } 214 }
215 pt->state = PT_STATE_INACTIVE; 215 pt->state = PT_STATE_INACTIVE;
216 if(pt->buf) 216 kfree(pt->buf);
217 kfree(pt->buf);
218 } 217 }
219} 218}
220 219
diff --git a/sound/oss/maestro.c b/sound/oss/maestro.c
index 52d2db4bc312..3dce504e6d6d 100644
--- a/sound/oss/maestro.c
+++ b/sound/oss/maestro.c
@@ -2356,7 +2356,7 @@ ess_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
2356 } 2356 }
2357 2357
2358rec_return_free: 2358rec_return_free:
2359 if(combbuf) kfree(combbuf); 2359 kfree(combbuf);
2360 return ret; 2360 return ret;
2361} 2361}
2362 2362
diff --git a/sound/oss/mpu401.c b/sound/oss/mpu401.c
index b66f53fa8db0..0aac54c68f01 100644
--- a/sound/oss/mpu401.c
+++ b/sound/oss/mpu401.c
@@ -1240,8 +1240,7 @@ void unload_mpu401(struct address_info *hw_config)
1240 p=mpu401_synth_operations[n]; 1240 p=mpu401_synth_operations[n];
1241 sound_unload_mididev(n); 1241 sound_unload_mididev(n);
1242 sound_unload_timerdev(hw_config->slots[2]); 1242 sound_unload_timerdev(hw_config->slots[2]);
1243 if(p) 1243 kfree(p);
1244 kfree(p);
1245 } 1244 }
1246} 1245}
1247 1246
diff --git a/sound/oss/sb_common.c b/sound/oss/sb_common.c
index ce359e6c933a..5f955e3d2e26 100644
--- a/sound/oss/sb_common.c
+++ b/sound/oss/sb_common.c
@@ -915,8 +915,8 @@ void sb_dsp_unload(struct address_info *hw_config, int sbmpu)
915 } 915 }
916 else 916 else
917 release_region(hw_config->io_base, 16); 917 release_region(hw_config->io_base, 16);
918 if(detected_devc) 918
919 kfree(detected_devc); 919 kfree(detected_devc);
920} 920}
921 921
922/* 922/*