Commit 0159f76d authored by Jesper Juhl's avatar Jesper Juhl Committed by Linus Torvalds

[PATCH] kfree cleanups in ixj.c

This patch removes redundant checks for NULL pointer before kfree() in
drivers/telephony/
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 89e0b113
...@@ -329,10 +329,8 @@ static IXJ *ixj_alloc() ...@@ -329,10 +329,8 @@ static IXJ *ixj_alloc()
static void ixj_fsk_free(IXJ *j) static void ixj_fsk_free(IXJ *j)
{ {
if(j->fskdata != NULL) { kfree(j->fskdata);
kfree(j->fskdata); j->fskdata = NULL;
j->fskdata = NULL;
}
} }
static void ixj_fsk_alloc(IXJ *j) static void ixj_fsk_alloc(IXJ *j)
...@@ -3867,13 +3865,11 @@ static int set_rec_codec(IXJ *j, int rate) ...@@ -3867,13 +3865,11 @@ static int set_rec_codec(IXJ *j, int rate)
j->rec_mode = 7; j->rec_mode = 7;
break; break;
default: default:
kfree(j->read_buffer);
j->rec_frame_size = 0; j->rec_frame_size = 0;
j->rec_mode = -1; j->rec_mode = -1;
if (j->read_buffer) { j->read_buffer = NULL;
kfree(j->read_buffer); j->read_buffer_size = 0;
j->read_buffer = NULL;
j->read_buffer_size = 0;
}
retval = 1; retval = 1;
break; break;
} }
...@@ -3991,14 +3987,12 @@ static int ixj_record_start(IXJ *j) ...@@ -3991,14 +3987,12 @@ static int ixj_record_start(IXJ *j)
static void ixj_record_stop(IXJ *j) static void ixj_record_stop(IXJ *j)
{ {
if(ixjdebug & 0x0002) if (ixjdebug & 0x0002)
printk("IXJ %d Stopping Record Codec %d at %ld\n", j->board, j->rec_codec, jiffies); printk("IXJ %d Stopping Record Codec %d at %ld\n", j->board, j->rec_codec, jiffies);
if (j->read_buffer) { kfree(j->read_buffer);
kfree(j->read_buffer); j->read_buffer = NULL;
j->read_buffer = NULL; j->read_buffer_size = 0;
j->read_buffer_size = 0;
}
if (j->rec_mode > -1) { if (j->rec_mode > -1) {
ixj_WriteDSPCommand(0x5120, j); ixj_WriteDSPCommand(0x5120, j);
j->rec_mode = -1; j->rec_mode = -1;
...@@ -4449,13 +4443,11 @@ static int set_play_codec(IXJ *j, int rate) ...@@ -4449,13 +4443,11 @@ static int set_play_codec(IXJ *j, int rate)
j->play_mode = 5; j->play_mode = 5;
break; break;
default: default:
kfree(j->write_buffer);
j->play_frame_size = 0; j->play_frame_size = 0;
j->play_mode = -1; j->play_mode = -1;
if (j->write_buffer) { j->write_buffer = NULL;
kfree(j->write_buffer); j->write_buffer_size = 0;
j->write_buffer = NULL;
j->write_buffer_size = 0;
}
retval = 1; retval = 1;
break; break;
} }
...@@ -4578,14 +4570,12 @@ static int ixj_play_start(IXJ *j) ...@@ -4578,14 +4570,12 @@ static int ixj_play_start(IXJ *j)
static void ixj_play_stop(IXJ *j) static void ixj_play_stop(IXJ *j)
{ {
if(ixjdebug & 0x0002) if (ixjdebug & 0x0002)
printk("IXJ %d Stopping Play Codec %d at %ld\n", j->board, j->play_codec, jiffies); printk("IXJ %d Stopping Play Codec %d at %ld\n", j->board, j->play_codec, jiffies);
if (j->write_buffer) { kfree(j->write_buffer);
kfree(j->write_buffer); j->write_buffer = NULL;
j->write_buffer = NULL; j->write_buffer_size = 0;
j->write_buffer_size = 0;
}
if (j->play_mode > -1) { if (j->play_mode > -1) {
ixj_WriteDSPCommand(0x5221, j); /* Stop playback and flush buffers. 8022 reference page 9-40 */ ixj_WriteDSPCommand(0x5221, j); /* Stop playback and flush buffers. 8022 reference page 9-40 */
...@@ -5810,9 +5800,7 @@ static void ixj_cpt_stop(IXJ *j) ...@@ -5810,9 +5800,7 @@ static void ixj_cpt_stop(IXJ *j)
ixj_play_tone(j, 0); ixj_play_tone(j, 0);
j->tone_state = j->tone_cadence_state = 0; j->tone_state = j->tone_cadence_state = 0;
if (j->cadence_t) { if (j->cadence_t) {
if (j->cadence_t->ce) { kfree(j->cadence_t->ce);
kfree(j->cadence_t->ce);
}
kfree(j->cadence_t); kfree(j->cadence_t);
j->cadence_t = NULL; j->cadence_t = NULL;
} }
...@@ -7497,10 +7485,8 @@ static void cleanup(void) ...@@ -7497,10 +7485,8 @@ static void cleanup(void)
printk(KERN_INFO "IXJ: Releasing XILINX address for /dev/phone%d\n", cnt); printk(KERN_INFO "IXJ: Releasing XILINX address for /dev/phone%d\n", cnt);
release_region(j->XILINXbase, 4); release_region(j->XILINXbase, 4);
} }
if (j->read_buffer) kfree(j->read_buffer);
kfree(j->read_buffer); kfree(j->write_buffer);
if (j->write_buffer)
kfree(j->write_buffer);
if (j->dev) if (j->dev)
pnp_device_detach(j->dev); pnp_device_detach(j->dev);
if (ixjdebug & 0x0002) if (ixjdebug & 0x0002)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment