diff options
author | Jesper Juhl <juhl-lkml@dif.dk> | 2005-04-18 17:39:34 -0700 |
---|---|---|
committer | Greg K-H <gregkh@suse.de> | 2005-04-18 17:39:34 -0700 |
commit | 1bc3c9e1e44c2059fe2ffa6ff70ad0a925d7b05f (patch) | |
tree | 0bc14ec53acf3b4c08a9995c7ea335e236435558 /drivers/usb | |
parent | 6fd19f4b55f7fd1c9d8650bd7f8df2c81b69c5ca (diff) |
[PATCH] USB: kfree cleanup for drivers/usb/* - no need to check for NULL
Get rid of a bunch of redundant NULL pointer checks in drivers/usb/*,
there's no need to check a pointer for NULL before calling kfree() on it.
Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Index: gregkh-2.6/drivers/usb/class/audio.c
===================================================================
Diffstat (limited to 'drivers/usb')
26 files changed, 91 insertions, 166 deletions
diff --git a/drivers/usb/class/audio.c b/drivers/usb/class/audio.c index f432b7d5b235..f8f21567cc22 100644 --- a/drivers/usb/class/audio.c +++ b/drivers/usb/class/audio.c @@ -649,14 +649,10 @@ static void usbin_stop(struct usb_audiodev *as) } } set_current_state(TASK_RUNNING); - if (u->durb[0].urb->transfer_buffer) - kfree(u->durb[0].urb->transfer_buffer); - if (u->durb[1].urb->transfer_buffer) - kfree(u->durb[1].urb->transfer_buffer); - if (u->surb[0].urb->transfer_buffer) - kfree(u->surb[0].urb->transfer_buffer); - if (u->surb[1].urb->transfer_buffer) - kfree(u->surb[1].urb->transfer_buffer); + kfree(u->durb[0].urb->transfer_buffer); + kfree(u->durb[1].urb->transfer_buffer); + kfree(u->surb[0].urb->transfer_buffer); + kfree(u->surb[1].urb->transfer_buffer); u->durb[0].urb->transfer_buffer = u->durb[1].urb->transfer_buffer = u->surb[0].urb->transfer_buffer = u->surb[1].urb->transfer_buffer = NULL; } @@ -1009,21 +1005,17 @@ static int usbin_start(struct usb_audiodev *as) u->phase = 0; maxsze = (u->freqmax + 0x3fff) >> (14 - AFMT_BYTESSHIFT(u->format)); bufsz = DESCFRAMES * maxsze; - if (u->durb[0].urb->transfer_buffer) - kfree(u->durb[0].urb->transfer_buffer); + kfree(u->durb[0].urb->transfer_buffer); u->durb[0].urb->transfer_buffer = kmalloc(bufsz, GFP_KERNEL); u->durb[0].urb->transfer_buffer_length = bufsz; - if (u->durb[1].urb->transfer_buffer) - kfree(u->durb[1].urb->transfer_buffer); + kfree(u->durb[1].urb->transfer_buffer); u->durb[1].urb->transfer_buffer = kmalloc(bufsz, GFP_KERNEL); u->durb[1].urb->transfer_buffer_length = bufsz; if (u->syncpipe) { - if (u->surb[0].urb->transfer_buffer) - kfree(u->surb[0].urb->transfer_buffer); + kfree(u->surb[0].urb->transfer_buffer); u->surb[0].urb->transfer_buffer = kmalloc(3*SYNCFRAMES, GFP_KERNEL); u->surb[0].urb->transfer_buffer_length = 3*SYNCFRAMES; - if (u->surb[1].urb->transfer_buffer) - kfree(u->surb[1].urb->transfer_buffer); + kfree(u->surb[1].urb->transfer_buffer); u->surb[1].urb->transfer_buffer = kmalloc(3*SYNCFRAMES, GFP_KERNEL); u->surb[1].urb->transfer_buffer_length = 3*SYNCFRAMES; } @@ -1128,14 +1120,10 @@ static void usbout_stop(struct usb_audiodev *as) } } set_current_state(TASK_RUNNING); - if (u->durb[0].urb->transfer_buffer) - kfree(u->durb[0].urb->transfer_buffer); - if (u->durb[1].urb->transfer_buffer) - kfree(u->durb[1].urb->transfer_buffer); - if (u->surb[0].urb->transfer_buffer) - kfree(u->surb[0].urb->transfer_buffer); - if (u->surb[1].urb->transfer_buffer) - kfree(u->surb[1].urb->transfer_buffer); + kfree(u->durb[0].urb->transfer_buffer); + kfree(u->durb[1].urb->transfer_buffer); + kfree(u->surb[0].urb->transfer_buffer); + kfree(u->surb[1].urb->transfer_buffer); u->durb[0].urb->transfer_buffer = u->durb[1].urb->transfer_buffer = u->surb[0].urb->transfer_buffer = u->surb[1].urb->transfer_buffer = NULL; } @@ -1376,21 +1364,17 @@ static int usbout_start(struct usb_audiodev *as) u->phase = 0; maxsze = (u->freqmax + 0x3fff) >> (14 - AFMT_BYTESSHIFT(u->format)); bufsz = DESCFRAMES * maxsze; - if (u->durb[0].urb->transfer_buffer) - kfree(u->durb[0].urb->transfer_buffer); + kfree(u->durb[0].urb->transfer_buffer); u->durb[0].urb->transfer_buffer = kmalloc(bufsz, GFP_KERNEL); u->durb[0].urb->transfer_buffer_length = bufsz; - if (u->durb[1].urb->transfer_buffer) - kfree(u->durb[1].urb->transfer_buffer); + kfree(u->durb[1].urb->transfer_buffer); u->durb[1].urb->transfer_buffer = kmalloc(bufsz, GFP_KERNEL); u->durb[1].urb->transfer_buffer_length = bufsz; if (u->syncpipe) { - if (u->surb[0].urb->transfer_buffer) - kfree(u->surb[0].urb->transfer_buffer); + kfree(u->surb[0].urb->transfer_buffer); u->surb[0].urb->transfer_buffer = kmalloc(3*SYNCFRAMES, GFP_KERNEL); u->surb[0].urb->transfer_buffer_length = 3*SYNCFRAMES; - if (u->surb[1].urb->transfer_buffer) - kfree(u->surb[1].urb->transfer_buffer); + kfree(u->surb[1].urb->transfer_buffer); u->surb[1].urb->transfer_buffer = kmalloc(3*SYNCFRAMES, GFP_KERNEL); u->surb[1].urb->transfer_buffer_length = 3*SYNCFRAMES; } diff --git a/drivers/usb/class/bluetty.c b/drivers/usb/class/bluetty.c index 6bac65e0ade7..524023327c49 100644 --- a/drivers/usb/class/bluetty.c +++ b/drivers/usb/class/bluetty.c @@ -309,7 +309,7 @@ static int bluetooth_ctrl_msg (struct usb_bluetooth *bluetooth, int request, int } } if (urb->transfer_buffer_length < len) { - kfree (urb->transfer_buffer); + kfree(urb->transfer_buffer); urb->transfer_buffer = kmalloc (len, GFP_KERNEL); if (urb->transfer_buffer == NULL) { err ("%s - out of memory", __FUNCTION__); @@ -535,7 +535,7 @@ static int bluetooth_write (struct tty_struct * tty, const unsigned char *buf, i } exit: - kfree (temp_buffer); + kfree(temp_buffer); return retval; } diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c index b87608b7051b..ef0b35731ff0 100644 --- a/drivers/usb/core/devices.c +++ b/drivers/usb/core/devices.c @@ -637,11 +637,8 @@ static int usb_device_open(struct inode *inode, struct file *file) static int usb_device_release(struct inode *inode, struct file *file) { - if (file->private_data) { - kfree(file->private_data); - file->private_data = NULL; - } - + kfree(file->private_data); + file->private_data = NULL; return 0; } diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 15ac4d168862..d2d648ee8640 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -381,7 +381,7 @@ static void hub_tt_kevent (void *arg) dev_err (&hdev->dev, "clear tt %d (%04x) error %d\n", clear->tt, clear->devinfo, status); - kfree (clear); + kfree(clear); } spin_unlock_irqrestore (&hub->tt.lock, flags); } @@ -728,15 +728,11 @@ static void hub_disconnect(struct usb_interface *intf) list_del_init(&hub->event_list); spin_unlock_irq(&hub_event_lock); - if (hub->descriptor) { - kfree(hub->descriptor); - hub->descriptor = NULL; - } + kfree(hub->descriptor); + hub->descriptor = NULL; - if (hub->status) { - kfree(hub->status); - hub->status = NULL; - } + kfree(hub->status); + hub->status = NULL; if (hub->buffer) { usb_buffer_free(hdev, sizeof(*hub->buffer), hub->buffer, @@ -2354,7 +2350,7 @@ check_highspeed (struct usb_hub *hub, struct usb_device *udev, int port1) schedule_work (&hub->leds); } } - kfree (qual); + kfree(qual); } static unsigned diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index 2af3f785d5a1..f1762ed6db63 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c @@ -2312,9 +2312,8 @@ static struct gs_buf *gs_buf_alloc(unsigned int size, int kmalloc_flags) */ void gs_buf_free(struct gs_buf *gb) { - if (gb != NULL) { - if (gb->buf_buf != NULL) - kfree(gb->buf_buf); + if (gb) { + kfree(gb->buf_buf); kfree(gb); } } diff --git a/drivers/usb/host/ehci-mem.c b/drivers/usb/host/ehci-mem.c index 9938697ff361..5c38ad869485 100644 --- a/drivers/usb/host/ehci-mem.c +++ b/drivers/usb/host/ehci-mem.c @@ -156,8 +156,7 @@ static void ehci_mem_cleanup (struct ehci_hcd *ehci) ehci->periodic = NULL; /* shadow periodic table */ - if (ehci->pshadow) - kfree (ehci->pshadow); + kfree(ehci->pshadow); ehci->pshadow = NULL; } diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index 98745a072d6f..49bd83ee0c75 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c @@ -890,8 +890,7 @@ up_failed: debugfs_remove(uhci_debugfs_root); debug_failed: - if (errbuf) - kfree(errbuf); + kfree(errbuf); errbuf_failed: @@ -906,9 +905,7 @@ static void __exit uhci_hcd_cleanup(void) warn("not all urb_priv's were freed!"); debugfs_remove(uhci_debugfs_root); - - if (errbuf) - kfree(errbuf); + kfree(errbuf); } module_init(uhci_hcd_init); diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index e625997694df..869ff73690ac 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c @@ -558,8 +558,7 @@ static void hid_free_device(struct hid_device *device) } } - if (device->rdesc) - kfree(device->rdesc); + kfree(device->rdesc); kfree(device); } diff --git a/drivers/usb/media/dabusb.c b/drivers/usb/media/dabusb.c index 8823297d2191..6ca2fae99d2d 100644 --- a/drivers/usb/media/dabusb.c +++ b/drivers/usb/media/dabusb.c @@ -138,8 +138,7 @@ static int dabusb_free_queue (struct list_head *q) #ifdef DEBUG dump_urb(b->purb); #endif - if (b->purb->transfer_buffer) - kfree (b->purb->transfer_buffer); + kfree(b->purb->transfer_buffer); usb_free_urb(b->purb); tmp = p->next; list_del (p); diff --git a/drivers/usb/media/ov511.c b/drivers/usb/media/ov511.c index 0fd7ffed3a98..d6051822416e 100644 --- a/drivers/usb/media/ov511.c +++ b/drivers/usb/media/ov511.c @@ -3915,10 +3915,8 @@ ov51x_do_dealloc(struct usb_ov511 *ov) ov->tempfbuf = NULL; for (i = 0; i < OV511_NUMSBUF; i++) { - if (ov->sbuf[i].data) { - kfree(ov->sbuf[i].data); - ov->sbuf[i].data = NULL; - } + kfree(ov->sbuf[i].data); + ov->sbuf[i].data = NULL; } for (i = 0; i < OV511_NUMFRAMES; i++) { @@ -5954,10 +5952,8 @@ error: up(&ov->cbuf_lock); } - if (ov) { - kfree(ov); - ov = NULL; - } + kfree(ov); + ov = NULL; error_out: err("Camera initialization failed"); diff --git a/drivers/usb/media/se401.c b/drivers/usb/media/se401.c index 685bdae5cb62..f69e443cd1bc 100644 --- a/drivers/usb/media/se401.c +++ b/drivers/usb/media/se401.c @@ -868,13 +868,14 @@ static void usb_se401_remove_disconnected (struct usb_se401 *se401) se401->dev = NULL; - for (i=0; i<SE401_NUMSBUF; i++) if (se401->urb[i]) { - usb_kill_urb(se401->urb[i]); - usb_free_urb(se401->urb[i]); - se401->urb[i] = NULL; - kfree(se401->sbuf[i].data); - } - for (i=0; i<SE401_NUMSCRATCH; i++) if (se401->scratch[i].data) { + for (i=0; i<SE401_NUMSBUF; i++) + if (se401->urb[i]) { + usb_kill_urb(se401->urb[i]); + usb_free_urb(se401->urb[i]); + se401->urb[i] = NULL; + kfree(se401->sbuf[i].data); + } + for (i=0; i<SE401_NUMSCRATCH; i++) { kfree(se401->scratch[i].data); } if (se401->inturb) { diff --git a/drivers/usb/media/usbvideo.c b/drivers/usb/media/usbvideo.c index 298484aa27d2..24efb21969c6 100644 --- a/drivers/usb/media/usbvideo.c +++ b/drivers/usb/media/usbvideo.c @@ -1169,10 +1169,8 @@ static int usbvideo_v4l_open(struct inode *inode, struct file *file) } RingQueue_Free(&uvd->dp); for (i=0; i < USBVIDEO_NUMSBUF; i++) { - if (uvd->sbuf[i].data != NULL) { - kfree (uvd->sbuf[i].data); - uvd->sbuf[i].data = NULL; - } + kfree(uvd->sbuf[i].data); + uvd->sbuf[i].data = NULL; } } } diff --git a/drivers/usb/media/w9968cf.c b/drivers/usb/media/w9968cf.c index 689e79e4bcee..ca9f3a30634f 100644 --- a/drivers/usb/media/w9968cf.c +++ b/drivers/usb/media/w9968cf.c @@ -3624,10 +3624,8 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) return 0; fail: /* Free unused memory */ - if (cam->control_buffer) - kfree(cam->control_buffer); - if (cam->data_buffer) - kfree(cam->data_buffer); + kfree(cam->control_buffer); + kfree(cam->data_buffer); if (cam->v4ldev) video_device_release(cam->v4ldev); up(&cam->dev_sem); diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c index a530bb976e43..6f7994f5a714 100644 --- a/drivers/usb/misc/auerswald.c +++ b/drivers/usb/misc/auerswald.c @@ -705,16 +705,12 @@ static int auerchain_control_msg (pauerchain_t acp, struct usb_device *dev, unsi /* free a single auerbuf */ static void auerbuf_free (pauerbuf_t bp) { - if (bp->bufp) { - kfree (bp->bufp); - } - if (bp->dr) { - kfree (bp->dr); - } + kfree(bp->bufp); + kfree(bp->dr); if (bp->urbp) { - usb_free_urb (bp->urbp); + usb_free_urb(bp->urbp); } - kfree (bp); + kfree(bp); } /* free the buffers from an auerbuf list */ @@ -1093,14 +1089,12 @@ exit: */ static void auerswald_int_free (pauerswald_t cp) { - if (cp->inturbp) { - usb_free_urb (cp->inturbp); - cp->inturbp = NULL; - } - if (cp->intbufp) { - kfree (cp->intbufp); - cp->intbufp = NULL; - } + if (cp->inturbp) { + usb_free_urb(cp->inturbp); + cp->inturbp = NULL; + } + kfree(cp->intbufp); + cp->intbufp = NULL; } /* This function is called to activate the interrupt diff --git a/drivers/usb/net/zd1201.c b/drivers/usb/net/zd1201.c index 938025e2c646..c81cd0a619bf 100644 --- a/drivers/usb/net/zd1201.c +++ b/drivers/usb/net/zd1201.c @@ -106,8 +106,7 @@ int zd1201_fw_upload(struct usb_device *dev, int apfw) err = 0; exit: - if (buf) - kfree(buf); + kfree(buf); release_firmware(fw_entry); return err; } diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c index 86994d117c44..abb1b2c543bb 100644 --- a/drivers/usb/serial/belkin_sa.c +++ b/drivers/usb/serial/belkin_sa.c @@ -202,8 +202,7 @@ static void belkin_sa_shutdown (struct usb_serial *serial) for (i=0; i < serial->num_ports; ++i) { /* My special items, the standard routines free my urbs */ priv = usb_get_serial_port_data(serial->port[i]); - if (priv) - kfree(priv); + kfree(priv); } } diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index db8f472d9e3f..d165f42d560d 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c @@ -1340,9 +1340,8 @@ static struct cypress_buf *cypress_buf_alloc(unsigned int size) static void cypress_buf_free(struct cypress_buf *cb) { - if (cb != NULL) { - if (cb->buf_buf != NULL) - kfree(cb->buf_buf); + if (cb) { + kfree(cb->buf_buf); kfree(cb); } } diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c index 4d46394f351b..8d562ab454a8 100644 --- a/drivers/usb/serial/empeg.c +++ b/drivers/usb/serial/empeg.c @@ -550,8 +550,7 @@ failed_usb_register: failed_usb_serial_register: for (i = 0; i < NUM_URBS; ++i) { if (write_urb_pool[i]) { - if (write_urb_pool[i]->transfer_buffer) - kfree(write_urb_pool[i]->transfer_buffer); + kfree(write_urb_pool[i]->transfer_buffer); usb_free_urb(write_urb_pool[i]); } } @@ -575,8 +574,7 @@ static void __exit empeg_exit (void) * the host controllers get fixed to set urb->dev = NULL after * the urb is finished. Otherwise this call oopses. */ /* usb_kill_urb(write_urb_pool[i]); */ - if (write_urb_pool[i]->transfer_buffer) - kfree(write_urb_pool[i]->transfer_buffer); + kfree(write_urb_pool[i]->transfer_buffer); usb_free_urb (write_urb_pool[i]); } } diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 4afd905fe2fe..4c788c767a97 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -1347,9 +1347,7 @@ static int ftdi_common_startup (struct usb_serial *serial) priv->flags = ASYNC_LOW_LATENCY; /* Increase the size of read buffers */ - if (port->bulk_in_buffer) { - kfree (port->bulk_in_buffer); - } + kfree(port->bulk_in_buffer); port->bulk_in_buffer = kmalloc (BUFSZ, GFP_KERNEL); if (!port->bulk_in_buffer) { kfree (priv); @@ -1365,10 +1363,8 @@ static int ftdi_common_startup (struct usb_serial *serial) usb_free_urb (port->write_urb); port->write_urb = NULL; } - if (port->bulk_out_buffer) { - kfree (port->bulk_out_buffer); - port->bulk_out_buffer = NULL; - } + kfree(port->bulk_out_buffer); + port->bulk_out_buffer = NULL; usb_set_serial_port_data(serial->port[0], priv); diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index e35b5adcd5fe..04bfe279d763 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -951,9 +951,7 @@ static void edge_bulk_out_cmd_callback (struct urb *urb, struct pt_regs *regs) /* clean up the transfer buffer */ - if (urb->transfer_buffer != NULL) { - kfree(urb->transfer_buffer); - } + kfree(urb->transfer_buffer); /* Free the command urb */ usb_free_urb (urb); @@ -1266,16 +1264,12 @@ static void edge_close (struct usb_serial_port *port, struct file * filp) if (edge_port->write_urb) { /* if this urb had a transfer buffer already (old transfer) free it */ - if (edge_port->write_urb->transfer_buffer != NULL) { - kfree(edge_port->write_urb->transfer_buffer); - } - usb_free_urb (edge_port->write_urb); + kfree(edge_port->write_urb->transfer_buffer); + usb_free_urb(edge_port->write_urb); edge_port->write_urb = NULL; } - if (edge_port->txfifo.fifo) { - kfree(edge_port->txfifo.fifo); - edge_port->txfifo.fifo = NULL; - } + kfree(edge_port->txfifo.fifo); + edge_port->txfifo.fifo = NULL; dbg("%s exited", __FUNCTION__); } @@ -1419,11 +1413,9 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge // get a pointer to the write_urb urb = edge_port->write_urb; - /* if this urb had a transfer buffer already (old transfer) free it */ - if (urb->transfer_buffer != NULL) { - kfree(urb->transfer_buffer); - urb->transfer_buffer = NULL; - } + /* make sure transfer buffer is freed */ + kfree(urb->transfer_buffer); + urb->transfer_buffer = NULL; /* build the data header for the buffer and port that we are about to send out */ count = fifo->count; diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index 6c96fdaec36e..ebf9967f7c86 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -2845,9 +2845,8 @@ static struct edge_buf *edge_buf_alloc(unsigned int size) void edge_buf_free(struct edge_buf *eb) { - if (eb != NULL) { - if (eb->buf_buf != NULL) - kfree(eb->buf_buf); + if (eb) { + kfree(eb->buf_buf); kfree(eb); } } diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index 49c602a0b4df..a11e829e38c8 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c @@ -341,8 +341,7 @@ static void klsi_105_shutdown (struct usb_serial *serial) * finished. Otherwise this call * oopses. */ /* usb_kill_urb(write_urbs[j]); */ - if (write_urbs[j]->transfer_buffer) - kfree(write_urbs[j]->transfer_buffer); + kfree(write_urbs[j]->transfer_buffer); usb_free_urb (write_urbs[j]); } } diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c index a1cba4b5fa23..b5f2c06d4f3e 100644 --- a/drivers/usb/serial/omninet.c +++ b/drivers/usb/serial/omninet.c @@ -178,7 +178,6 @@ static void omninet_close (struct usb_serial_port *port, struct file * filp) { struct usb_serial *serial = port->serial; struct usb_serial_port *wport; - struct omninet_data *od; dbg("%s - port %d", __FUNCTION__, port->number); @@ -186,9 +185,7 @@ static void omninet_close (struct usb_serial_port *port, struct file * filp) usb_kill_urb(wport->write_urb); usb_kill_urb(port->read_urb); - od = usb_get_serial_port_data(port); - if (od) - kfree(od); + kfree(usb_get_serial_port_data(port)); } diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 8e9b007bf44d..7eab5d4cf3a8 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -1044,9 +1044,8 @@ static struct pl2303_buf *pl2303_buf_alloc(unsigned int size) static void pl2303_buf_free(struct pl2303_buf *pb) { - if (pb != NULL) { - if (pb->buf_buf != NULL) - kfree(pb->buf_buf); + if (pb) { + kfree(pb->buf_buf); kfree(pb); } } diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 98054876cca2..59c88de3e7ae 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c @@ -517,8 +517,7 @@ static void ti_shutdown(struct usb_serial *serial) } } - if (tdev) - kfree(tdev); + kfree(tdev); usb_set_serial_data(serial, NULL); } diff --git a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c index 229ca181716b..8451779f4269 100644 --- a/drivers/usb/storage/sddr55.c +++ b/drivers/usb/storage/sddr55.c @@ -119,10 +119,8 @@ static int sddr55_status(struct us_data *us) /* expect to get short transfer if no card fitted */ if (result == USB_STOR_XFER_SHORT || result == USB_STOR_XFER_STALLED) { /* had a short transfer, no card inserted, free map memory */ - if (info->lba_to_pba) - kfree(info->lba_to_pba); - if (info->pba_to_lba) - kfree(info->pba_to_lba); + kfree(info->lba_to_pba); + kfree(info->pba_to_lba); info->lba_to_pba = NULL; info->pba_to_lba = NULL; @@ -649,18 +647,14 @@ static int sddr55_read_map(struct us_data *us) { return -1; } - if (info->lba_to_pba) - kfree(info->lba_to_pba); - if (info->pba_to_lba) - kfree(info->pba_to_lba); + kfree(info->lba_to_pba); + kfree(info->pba_to_lba); info->lba_to_pba = kmalloc(numblocks*sizeof(int), GFP_NOIO); info->pba_to_lba = kmalloc(numblocks*sizeof(int), GFP_NOIO); if (info->lba_to_pba == NULL || info->pba_to_lba == NULL) { - if (info->lba_to_pba != NULL) - kfree(info->lba_to_pba); - if (info->pba_to_lba != NULL) - kfree(info->pba_to_lba); + kfree(info->lba_to_pba); + kfree(info->pba_to_lba); info->lba_to_pba = NULL; info->pba_to_lba = NULL; kfree(buffer); @@ -728,10 +722,8 @@ static void sddr55_card_info_destructor(void *extra) { if (!extra) return; - if (info->lba_to_pba) - kfree(info->lba_to_pba); - if (info->pba_to_lba) - kfree(info->pba_to_lba); + kfree(info->lba_to_pba); + kfree(info->pba_to_lba); } |