aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial
diff options
context:
space:
mode:
authorJesper Juhl <juhl-lkml@dif.dk>2005-04-18 20:39:34 -0400
committerGreg K-H <gregkh@suse.de>2005-04-18 20:39:34 -0400
commit1bc3c9e1e44c2059fe2ffa6ff70ad0a925d7b05f (patch)
tree0bc14ec53acf3b4c08a9995c7ea335e236435558 /drivers/usb/serial
parent6fd19f4b55f7fd1c9d8650bd7f8df2c81b69c5ca (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/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)
202 for (i=0; i < serial->num_ports; ++i) { 202 for (i=0; i < serial->num_ports; ++i) {
203 /* My special items, the standard routines free my urbs */ 203 /* My special items, the standard routines free my urbs */
204 priv = usb_get_serial_port_data(serial->port[i]); 204 priv = usb_get_serial_port_data(serial->port[i]);
205 if (priv) 205 kfree(priv);
206 kfree(priv);
207 } 206 }
208} 207}
209 208
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)
1340 1340
1341static void cypress_buf_free(struct cypress_buf *cb) 1341static void cypress_buf_free(struct cypress_buf *cb)
1342{ 1342{
1343 if (cb != NULL) { 1343 if (cb) {
1344 if (cb->buf_buf != NULL) 1344 kfree(cb->buf_buf);
1345 kfree(cb->buf_buf);
1346 kfree(cb); 1345 kfree(cb);
1347 } 1346 }
1348} 1347}
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:
550failed_usb_serial_register: 550failed_usb_serial_register:
551 for (i = 0; i < NUM_URBS; ++i) { 551 for (i = 0; i < NUM_URBS; ++i) {
552 if (write_urb_pool[i]) { 552 if (write_urb_pool[i]) {
553 if (write_urb_pool[i]->transfer_buffer) 553 kfree(write_urb_pool[i]->transfer_buffer);
554 kfree(write_urb_pool[i]->transfer_buffer);
555 usb_free_urb(write_urb_pool[i]); 554 usb_free_urb(write_urb_pool[i]);
556 } 555 }
557 } 556 }
@@ -575,8 +574,7 @@ static void __exit empeg_exit (void)
575 * the host controllers get fixed to set urb->dev = NULL after 574 * the host controllers get fixed to set urb->dev = NULL after
576 * the urb is finished. Otherwise this call oopses. */ 575 * the urb is finished. Otherwise this call oopses. */
577 /* usb_kill_urb(write_urb_pool[i]); */ 576 /* usb_kill_urb(write_urb_pool[i]); */
578 if (write_urb_pool[i]->transfer_buffer) 577 kfree(write_urb_pool[i]->transfer_buffer);
579 kfree(write_urb_pool[i]->transfer_buffer);
580 usb_free_urb (write_urb_pool[i]); 578 usb_free_urb (write_urb_pool[i]);
581 } 579 }
582 } 580 }
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)
1347 priv->flags = ASYNC_LOW_LATENCY; 1347 priv->flags = ASYNC_LOW_LATENCY;
1348 1348
1349 /* Increase the size of read buffers */ 1349 /* Increase the size of read buffers */
1350 if (port->bulk_in_buffer) { 1350 kfree(port->bulk_in_buffer);
1351 kfree (port->bulk_in_buffer);
1352 }
1353 port->bulk_in_buffer = kmalloc (BUFSZ, GFP_KERNEL); 1351 port->bulk_in_buffer = kmalloc (BUFSZ, GFP_KERNEL);
1354 if (!port->bulk_in_buffer) { 1352 if (!port->bulk_in_buffer) {
1355 kfree (priv); 1353 kfree (priv);
@@ -1365,10 +1363,8 @@ static int ftdi_common_startup (struct usb_serial *serial)
1365 usb_free_urb (port->write_urb); 1363 usb_free_urb (port->write_urb);
1366 port->write_urb = NULL; 1364 port->write_urb = NULL;
1367 } 1365 }
1368 if (port->bulk_out_buffer) { 1366 kfree(port->bulk_out_buffer);
1369 kfree (port->bulk_out_buffer); 1367 port->bulk_out_buffer = NULL;
1370 port->bulk_out_buffer = NULL;
1371 }
1372 1368
1373 usb_set_serial_port_data(serial->port[0], priv); 1369 usb_set_serial_port_data(serial->port[0], priv);
1374 1370
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)
951 951
952 952
953 /* clean up the transfer buffer */ 953 /* clean up the transfer buffer */
954 if (urb->transfer_buffer != NULL) { 954 kfree(urb->transfer_buffer);
955 kfree(urb->transfer_buffer);
956 }
957 955
958 /* Free the command urb */ 956 /* Free the command urb */
959 usb_free_urb (urb); 957 usb_free_urb (urb);
@@ -1266,16 +1264,12 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
1266 1264
1267 if (edge_port->write_urb) { 1265 if (edge_port->write_urb) {
1268 /* if this urb had a transfer buffer already (old transfer) free it */ 1266 /* if this urb had a transfer buffer already (old transfer) free it */
1269 if (edge_port->write_urb->transfer_buffer != NULL) { 1267 kfree(edge_port->write_urb->transfer_buffer);
1270 kfree(edge_port->write_urb->transfer_buffer); 1268 usb_free_urb(edge_port->write_urb);
1271 }
1272 usb_free_urb (edge_port->write_urb);
1273 edge_port->write_urb = NULL; 1269 edge_port->write_urb = NULL;
1274 } 1270 }
1275 if (edge_port->txfifo.fifo) { 1271 kfree(edge_port->txfifo.fifo);
1276 kfree(edge_port->txfifo.fifo); 1272 edge_port->txfifo.fifo = NULL;
1277 edge_port->txfifo.fifo = NULL;
1278 }
1279 1273
1280 dbg("%s exited", __FUNCTION__); 1274 dbg("%s exited", __FUNCTION__);
1281} 1275}
@@ -1419,11 +1413,9 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge
1419 // get a pointer to the write_urb 1413 // get a pointer to the write_urb
1420 urb = edge_port->write_urb; 1414 urb = edge_port->write_urb;
1421 1415
1422 /* if this urb had a transfer buffer already (old transfer) free it */ 1416 /* make sure transfer buffer is freed */
1423 if (urb->transfer_buffer != NULL) { 1417 kfree(urb->transfer_buffer);
1424 kfree(urb->transfer_buffer); 1418 urb->transfer_buffer = NULL;
1425 urb->transfer_buffer = NULL;
1426 }
1427 1419
1428 /* build the data header for the buffer and port that we are about to send out */ 1420 /* build the data header for the buffer and port that we are about to send out */
1429 count = fifo->count; 1421 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)
2845 2845
2846void edge_buf_free(struct edge_buf *eb) 2846void edge_buf_free(struct edge_buf *eb)
2847{ 2847{
2848 if (eb != NULL) { 2848 if (eb) {
2849 if (eb->buf_buf != NULL) 2849 kfree(eb->buf_buf);
2850 kfree(eb->buf_buf);
2851 kfree(eb); 2850 kfree(eb);
2852 } 2851 }
2853} 2852}
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)
341 * finished. Otherwise this call 341 * finished. Otherwise this call
342 * oopses. */ 342 * oopses. */
343 /* usb_kill_urb(write_urbs[j]); */ 343 /* usb_kill_urb(write_urbs[j]); */
344 if (write_urbs[j]->transfer_buffer) 344 kfree(write_urbs[j]->transfer_buffer);
345 kfree(write_urbs[j]->transfer_buffer);
346 usb_free_urb (write_urbs[j]); 345 usb_free_urb (write_urbs[j]);
347 } 346 }
348 } 347 }
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)
178{ 178{
179 struct usb_serial *serial = port->serial; 179 struct usb_serial *serial = port->serial;
180 struct usb_serial_port *wport; 180 struct usb_serial_port *wport;
181 struct omninet_data *od;
182 181
183 dbg("%s - port %d", __FUNCTION__, port->number); 182 dbg("%s - port %d", __FUNCTION__, port->number);
184 183
@@ -186,9 +185,7 @@ static void omninet_close (struct usb_serial_port *port, struct file * filp)
186 usb_kill_urb(wport->write_urb); 185 usb_kill_urb(wport->write_urb);
187 usb_kill_urb(port->read_urb); 186 usb_kill_urb(port->read_urb);
188 187
189 od = usb_get_serial_port_data(port); 188 kfree(usb_get_serial_port_data(port));
190 if (od)
191 kfree(od);
192} 189}
193 190
194 191
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)
1044 1044
1045static void pl2303_buf_free(struct pl2303_buf *pb) 1045static void pl2303_buf_free(struct pl2303_buf *pb)
1046{ 1046{
1047 if (pb != NULL) { 1047 if (pb) {
1048 if (pb->buf_buf != NULL) 1048 kfree(pb->buf_buf);
1049 kfree(pb->buf_buf);
1050 kfree(pb); 1049 kfree(pb);
1051 } 1050 }
1052} 1051}
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)
517 } 517 }
518 } 518 }
519 519
520 if (tdev) 520 kfree(tdev);
521 kfree(tdev);
522 usb_set_serial_data(serial, NULL); 521 usb_set_serial_data(serial, NULL);
523} 522}
524 523