[PATCH] USB: kfree cleanup for drivers/usb/* - no need to check for NULL
authorJesper Juhl <juhl-lkml@dif.dk>
Tue, 19 Apr 2005 00:39:34 +0000 (17:39 -0700)
committerGreg K-H <gregkh@suse.de>
Tue, 19 Apr 2005 00:39:34 +0000 (17:39 -0700)
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
===================================================================

26 files changed:
drivers/usb/class/audio.c
drivers/usb/class/bluetty.c
drivers/usb/core/devices.c
drivers/usb/core/hub.c
drivers/usb/gadget/serial.c
drivers/usb/host/ehci-mem.c
drivers/usb/host/uhci-hcd.c
drivers/usb/input/hid-core.c
drivers/usb/media/dabusb.c
drivers/usb/media/ov511.c
drivers/usb/media/se401.c
drivers/usb/media/usbvideo.c
drivers/usb/media/w9968cf.c
drivers/usb/misc/auerswald.c
drivers/usb/net/zd1201.c
drivers/usb/serial/belkin_sa.c
drivers/usb/serial/cypress_m8.c
drivers/usb/serial/empeg.c
drivers/usb/serial/ftdi_sio.c
drivers/usb/serial/io_edgeport.c
drivers/usb/serial/io_ti.c
drivers/usb/serial/kl5kusb105.c
drivers/usb/serial/omninet.c
drivers/usb/serial/pl2303.c
drivers/usb/serial/ti_usb_3410_5052.c
drivers/usb/storage/sddr55.c

index f432b7d5b2357f45be0790f16a34f922d396b26f..f8f21567cc22489c505d104851c80ab03fe8e47f 100644 (file)
@@ -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;
                }
index 6bac65e0ade74e2877f2d5c9f62315e07bd08493..524023327c4900a18493c6691015a4fbf143af2b 100644 (file)
@@ -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;
 } 
index b87608b7051bf960cdd3f3ed4a88635e249de173..ef0b35731ff078789d4129ca32bbfe4e4f542a19 100644 (file)
@@ -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;
 }
 
index 15ac4d16886274579d091994cf1be5e949af26c5..d2d648ee864009cc028d2ce539ffede88f9bf17f 100644 (file)
@@ -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
index 2af3f785d5a11c92926b7891c486f7fb762501a3..f1762ed6db6394aefd5340ddabc8692f56d89fbc 100644 (file)
@@ -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);
        }
 }
index 9938697ff361372e62814f45f48d4393566147ac..5c38ad869485e8870f20d1834f78eb264cbe8104 100644 (file)
@@ -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;
 }
 
index 98745a072d6fe69afa5134b33aa8aab6d70f94bb..49bd83ee0c75bd77eded16e1fa3d02484f2d784a 100644 (file)
@@ -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);
index e625997694df9f5ee5fa96a32323b552dd2a1794..869ff73690acebf04655691c4edc01a017a6abe4 100644 (file)
@@ -558,8 +558,7 @@ static void hid_free_device(struct hid_device *device)
                }
        }
 
-       if (device->rdesc)
-               kfree(device->rdesc);
+       kfree(device->rdesc);
        kfree(device);
 }
 
index 8823297d219165b4e899f62b1a51cc8ade8728e6..6ca2fae99d2d75026bec3d29007378171fd14274 100644 (file)
@@ -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);
index 0fd7ffed3a980155c3514cd1da68246995e298fd..d6051822416e0a4601828e41545125fe25f9819b 100644 (file)
@@ -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");
index 685bdae5cb626f4d3263156097938885352072fd..f69e443cd1bcda63b6c4e4eb6396676f85a3124e 100644 (file)
@@ -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) {
index 298484aa27d2432999f740ca102239ed5365652d..24efb21969c6ce34d15490bb70c576b5879ce7a2 100644 (file)
@@ -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;
                        }
                }
        }
index 689e79e4bcee8ba61bde2f858ee6792506e04a20..ca9f3a30634fef6eb3f9fb2aed8d319b33aa660b 100644 (file)
@@ -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);
index a530bb976e437d941e25b65df302d186d8797df3..6f7994f5a714b19e1552aa485ebb6240cac93e67 100644 (file)
@@ -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
index 938025e2c6469a0aeefd3987a2cde9ee54b1634b..c81cd0a619bfcf1841b611f79b946956fbc82591 100644 (file)
@@ -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;
 }
index 86994d117c44aa249d057b94d9f42d0aa4ede6f2..abb1b2c543bbe11a7509857599024c8c7fdc3b6a 100644 (file)
@@ -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);
        }
 }
 
index db8f472d9e3f279ef72ab8dba68296cf8a841b07..d165f42d560d6282751c6f81075eced95994341c 100644 (file)
@@ -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);
        }
 }
index 4d46394f351b184bd778bc5aa3d4c5a9c6405ce4..8d562ab454a8589335d1d6350b80bfe6b32b0c80 100644 (file)
@@ -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]);
                }
        }
index 4afd905fe2fe429ffcb766678a68e212c925dc5a..4c788c767a97f890df4f24741f4d47518bc1a6ee 100644 (file)
@@ -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);
        
index e35b5adcd5fe71821b8a5f0ff03ed0ebb782d4ba..04bfe279d763bd15e2bf48eefb71a84b2bff07c8 100644 (file)
@@ -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;
index 6c96fdaec36e3a4de5007494073904b5116f7ff5..ebf9967f7c86f3e76998e3fb8a3b348a0eeef2c1 100644 (file)
@@ -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);
        }
 }
index 49c602a0b4dfc1399b9f062474bb4457b2a4ad05..a11e829e38c8a04e8c90b1d3fa8f262176a4b41e 100644 (file)
@@ -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]);
                                }
                        }
index a1cba4b5fa2352243b48c363afb485d07db275d9..b5f2c06d4f3e6a69e713dc4250cd6519ac00ec75 100644 (file)
@@ -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));
 }
 
 
index 8e9b007bf44d2a4b3e94c41a3f0f10fd7b28f1d1..7eab5d4cf3a8c674a84ebafd73c8e4aaa4e2da27 100644 (file)
@@ -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);
        }
 }
index 98054876cca25f8c9fea8d9201e2e1d921dbd5e8..59c88de3e7ae337459ea7cea7262639fe28d5e5e 100644 (file)
@@ -517,8 +517,7 @@ static void ti_shutdown(struct usb_serial *serial)
                }
        }
 
-       if (tdev)
-               kfree(tdev);
+       kfree(tdev);
        usb_set_serial_data(serial, NULL);
 }
 
index 229ca181716b507934db9daeca07990a7774c0c6..8451779f4269836f41a56cb06a38dfa479b2e7c1 100644 (file)
@@ -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);
 }