summaryrefslogtreecommitdiff
path: root/drivers/usb/serial
diff options
context:
space:
mode:
authorJesper Juhl <juhl-lkml@dif.dk>2005-04-19 04:39:34 +0400
committerGreg K-H <gregkh@suse.de>2005-04-19 04:39:34 +0400
commit1bc3c9e1e44c2059fe2ffa6ff70ad0a925d7b05f (patch)
tree0bc14ec53acf3b4c08a9995c7ea335e236435558 /drivers/usb/serial
parent6fd19f4b55f7fd1c9d8650bd7f8df2c81b69c5ca (diff)
downloadlinux-1bc3c9e1e44c2059fe2ffa6ff70ad0a925d7b05f.tar.xz
[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/serial')
-rw-r--r--drivers/usb/serial/belkin_sa.c3
-rw-r--r--drivers/usb/serial/cypress_m8.c5
-rw-r--r--drivers/usb/serial/empeg.c6
-rw-r--r--drivers/usb/serial/ftdi_sio.c10
-rw-r--r--drivers/usb/serial/io_edgeport.c24
-rw-r--r--drivers/usb/serial/io_ti.c5
-rw-r--r--drivers/usb/serial/kl5kusb105.c3
-rw-r--r--drivers/usb/serial/omninet.c5
-rw-r--r--drivers/usb/serial/pl2303.c5
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c3
10 files changed, 23 insertions, 46 deletions
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);
}