* mos7840_startup() blindly calls kfree() on memory that may have never been
  allocated.

Signed-off-by: Mark Ferrell <mferr...@uplogix.com>

---
 drivers/usb/serial/mos7840.c |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 57eca24..1afb141 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -2678,10 +2678,15 @@ error:
        for (/* nothing */; i >= 0; i--) {
                mos7840_port = mos7840_get_port_private(serial->port[i]);
 
-               kfree(mos7840_port->dr);
-               kfree(mos7840_port->ctrl_buf);
-               usb_free_urb(mos7840_port->control_urb);
-               kfree(mos7840_port);
+               if (mos7840_port) {
+                       if (mos7840_port->control_urb)
+                               usb_free_urb(mos7840_port->control_urb);
+                       if (mos7840_port->ctrl_buf)
+                               kfree(mos7840_port->ctrl_buf);
+                       if (mos7840_port->dr)
+                               kfree(mos7840_port->dr);
+                       kfree(mos7840_port);
+               }
                serial->port[i] = NULL;
        }
        return status;
-- 
tg: (8a7298b..) usb/serial/mos7840/kfree (depends on: master)
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to