Commit 09417379 authored by Jesper Juhl's avatar Jesper Juhl Committed by Linus Torvalds
Browse files

[PATCH] remove redundant NULL checks before kfree() in sound/ and avoid...


[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: default avatarJesper Juhl <juhl-lkml@dif.dk>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 4ae6673e
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -2178,7 +2178,6 @@ void ad1848_unload(int io_base, int irq, int dma_playback, int dma_capture, int
		
	if (devc != NULL)
	{
		if(audio_devs[dev]->portc!=NULL)
		kfree(audio_devs[dev]->portc);
		release_region(devc->base, 4);

+1 −2
Original line number Diff line number Diff line
@@ -277,7 +277,6 @@ static void ad1889_free_dev(ad1889_dev_t *dev)

	for (j = 0; j < AD_MAX_STATES; j++) {
		dmabuf = &dev->state[j].dmabuf;
		if (dmabuf->rawbuf != NULL) 
		kfree(dmabuf->rawbuf);
	}

+7 −13
Original line number Diff line number Diff line
@@ -671,13 +671,9 @@ static void PMacIrqCleanup(void)
	release_OF_resource(awacs_node, 1);
	release_OF_resource(awacs_node, 2);

	if (awacs_tx_cmd_space)
	kfree(awacs_tx_cmd_space);
	if (awacs_rx_cmd_space)
	kfree(awacs_rx_cmd_space);
	if (beep_dbdma_cmd_space)
	kfree(beep_dbdma_cmd_space);
	if (beep_buf)
	kfree(beep_buf);
#ifdef CONFIG_PMAC_PBOOK
	pmu_unregister_sleep_notifier(&awacs_sleep_notifier);
@@ -2301,7 +2297,6 @@ if (count <= 0)
#endif

	if ((write_sq.max_count + 1) > number_of_tx_cmd_buffers) {
		if (awacs_tx_cmd_space)
		kfree(awacs_tx_cmd_space);
		number_of_tx_cmd_buffers = 0;

@@ -2360,7 +2355,6 @@ if (count <= 0)
#endif

	if ((read_sq.max_count+1) > number_of_rx_cmd_buffers ) {
		if (awacs_rx_cmd_space)
		kfree(awacs_rx_cmd_space);
		number_of_rx_cmd_buffers = 0;

@@ -2805,7 +2799,7 @@ __init setup_beep(void)
	beep_buf = (short *) kmalloc(BEEP_BUFLEN * 4, GFP_KERNEL);
	if (beep_buf == NULL) {
		printk(KERN_ERR "dmasound_pmac: no memory for beep buffer\n");
		if( beep_dbdma_cmd_space ) kfree(beep_dbdma_cmd_space) ;
		kfree(beep_dbdma_cmd_space) ;
		return -ENOMEM ;
	}
	return 0 ;
+2 −4
Original line number Diff line number Diff line
@@ -523,11 +523,9 @@ void emu10k1_seq_midi_close(int dev)
	card = midi_devs[dev]->devc;
	emu10k1_mpuout_close(card);

	if (card->seq_mididev) {
	kfree(card->seq_mididev);
	card->seq_mididev = NULL;
}
}

int emu10k1_seq_midi_out(int dev, unsigned char midi_byte)
{
+1 −2
Original line number Diff line number Diff line
@@ -213,7 +213,6 @@ void emu10k1_pt_stop(struct emu10k1_card *card)
				sblive_writeptr(card, SPCS0 + i, 0, pt->old_spcs[i]);
		}
		pt->state = PT_STATE_INACTIVE;
		if(pt->buf)
		kfree(pt->buf);
	}
}
Loading