Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=0d46c0079a8eeed25105fa374f79862842ee80c1
Commit:     0d46c0079a8eeed25105fa374f79862842ee80c1
Parent:     167a675a8caa249f8bc9053c02d711545d1f7662
Author:     Jesper Juhl <[EMAIL PROTECTED]>
AuthorDate: Mon Jul 16 22:17:25 2007 +0200
Committer:  Greg Kroah-Hartman <[EMAIL PROTECTED]>
CommitDate: Thu Jul 19 17:46:05 2007 -0700

    USB: Remove pointless conditional in 
drivers/usb/serial/io_ti.c::edge_shutdown()
    
    Coverity scan found (CID: 1708) this in
    drivers/usb/serial/io_ti.c::edge_shutdown() :
    
    ...
    2797                for (i=0; i < serial->num_ports; ++i) {
    2798                        edge_port = 
usb_get_serial_port_data(serial->port[i]);
    2799                        edge_remove_sysfs_attrs(edge_port->port);
    2800                        if (edge_port) {
    2801                                edge_buf_free(edge_port->ep_out_buf);
    2802                                kfree(edge_port);
    2803                        }
    2804                        usb_set_serial_port_data(serial->port[i], NULL);
    2805                }
    ...
    
    It's complaining that we dereference 'edge_port' in line 2799 which
    makes the test of that pointer against NULL in 2800 pointless, since if
    edge_port was actually NULL we'd have crashed already before reaching
    line 2800.
    Reading the edge_open() function it seems to me that the pointer
    returned by usb_get_serial_port_data(serial->port[i]) and stored in
    'edge_port' can never actually be NULL here, so the test is entirely
    superfluous (even if it could be NULL it would be pointless here,
    ignoring the then possible crash in that case, since both
    edge_buf_free() and kfree() can handle being passed NULL pointers.
    
    This patch removes the pointless conditional (and also makes a few
    tiny style corrections now that I was in the area anyway).
    
    
    Signed-off-by: Jesper Juhl <[EMAIL PROTECTED]>
    Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>
---
 drivers/usb/serial/io_ti.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index 0d39036..b867090 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -2794,16 +2794,14 @@ static void edge_shutdown (struct usb_serial *serial)
 
        dbg ("%s", __FUNCTION__);
 
-       for (i=0; i < serial->num_ports; ++i) {
+       for (i = 0; i < serial->num_ports; ++i) {
                edge_port = usb_get_serial_port_data(serial->port[i]);
                edge_remove_sysfs_attrs(edge_port->port);
-               if (edge_port) {
-                       edge_buf_free(edge_port->ep_out_buf);
-                       kfree(edge_port);
-               }
+               edge_buf_free(edge_port->ep_out_buf);
+               kfree(edge_port);
                usb_set_serial_port_data(serial->port[i], NULL);
        }
-       kfree (usb_get_serial_data(serial));
+       kfree(usb_get_serial_data(serial));
        usb_set_serial_data(serial, NULL);
 }
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to