]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
fix up queue-3.6/usb-iuu_phoenix-fix-port-data-memory-leak.patch
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 24 Oct 2012 17:08:22 +0000 (10:08 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 24 Oct 2012 17:08:22 +0000 (10:08 -0700)
queue-3.6/usb-iuu_phoenix-fix-port-data-memory-leak.patch

index c47d322baca97234558c68a551d3f92263b730da..782c03c96b8b46a017db716b562a5d89f70fb963 100644 (file)
@@ -19,55 +19,67 @@ Compile-only tested.
 Signed-off-by: Johan Hovold <jhovold@gmail.com>
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 
+---
+ drivers/usb/serial/iuu_phoenix.c |   70 ++++++++++++++++-----------------------
+ 1 file changed, 30 insertions(+), 40 deletions(-)
+
 --- a/drivers/usb/serial/iuu_phoenix.c
 +++ b/drivers/usb/serial/iuu_phoenix.c
-@@ -72,63 +72,45 @@ struct iuu_private {
+@@ -80,64 +80,54 @@ struct iuu_private {
        u32 clk;
  };
  
 -
 -static void iuu_free_buf(struct iuu_private *priv)
--{
++static int iuu_port_probe(struct usb_serial_port *port)
+ {
 -      kfree(priv->buf);
+-      kfree(priv->dbgbuf);
 -      kfree(priv->writebuf);
 -}
--
--static int iuu_alloc_buf(struct usb_serial *serial, struct iuu_private *priv)
++      struct iuu_private *priv;
++
++      priv = kzalloc(sizeof(struct iuu_private), GFP_KERNEL);
++      if (!priv)
++              return -ENOMEM;
+-static int iuu_alloc_buf(struct iuu_private *priv)
 -{
--      priv->buf = kzalloc(256, GFP_KERNEL);
+       priv->buf = kzalloc(256, GFP_KERNEL);
+-      priv->dbgbuf = kzalloc(256, GFP_KERNEL);
 -      priv->writebuf = kzalloc(256, GFP_KERNEL);
--      if (!priv->buf || !priv->writebuf) {
+-      if (!priv->buf || !priv->dbgbuf || !priv->writebuf) {
 -              iuu_free_buf(priv);
--              dev_dbg(&serial->dev->dev, "%s problem allocation buffer\n", __func__);
--              return -ENOMEM;
--      }
--      dev_dbg(&serial->dev->dev, "%s - Privates buffers allocation success\n", __func__);
--      return 0;
--}
--
--static int iuu_startup(struct usb_serial *serial)
-+static int iuu_port_probe(struct usb_serial_port *port)
- {
-       struct iuu_private *priv;
-       priv = kzalloc(sizeof(struct iuu_private), GFP_KERNEL);
--      dev_dbg(&serial->dev->dev, "%s- priv allocation success\n", __func__);
-       if (!priv)
-               return -ENOMEM;
--      if (iuu_alloc_buf(serial, priv)) {
-+
-+      priv->buf = kzalloc(256, GFP_KERNEL);
+-              dbg("%s problem allocation buffer", __func__);
 +      if (!priv->buf) {
-               kfree(priv);
++              kfree(priv);
                return -ENOMEM;
        }
-+
+-      dbg("%s - Privates buffers allocation success", __func__);
+-      return 0;
+-}
+-static int iuu_startup(struct usb_serial *serial)
+-{
+-      struct iuu_private *priv;
+-      priv = kzalloc(sizeof(struct iuu_private), GFP_KERNEL);
+-      dbg("%s- priv allocation success", __func__);
+-      if (!priv)
 +      priv->writebuf = kzalloc(256, GFP_KERNEL);
 +      if (!priv->writebuf) {
 +              kfree(priv->buf);
 +              kfree(priv);
-+              return -ENOMEM;
+               return -ENOMEM;
+-      if (iuu_alloc_buf(priv)) {
 +      }
++
++      priv->dbgbuf = kzalloc(256, GFP_KERNEL);
++      if (!priv->writebuf) {
++              kfree(priv->writebuf);
++              kfree(priv->buf);
+               kfree(priv);
+               return -ENOMEM;
+       }
 +
        priv->vcc = vcc_default;
        spin_lock_init(&priv->lock);
@@ -90,22 +102,23 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -
 -      if (priv) {
 -              iuu_free_buf(priv);
--              dev_dbg(&port->dev, "%s - I will free all\n", __func__);
+-              dbg("%s - I will free all", __func__);
 -              usb_set_serial_port_data(port, NULL);
  
--              dev_dbg(&port->dev, "%s - priv is not anymore in port structure\n", __func__);
+-              dbg("%s - priv is not anymore in port structure", __func__);
 -              kfree(priv);
++      kfree(priv->dbgbuf);
 +      kfree(priv->writebuf);
 +      kfree(priv->buf);
 +      kfree(priv);
  
--              dev_dbg(&port->dev, "%s priv is now kfree\n", __func__);
+-              dbg("%s priv is now kfree", __func__);
 -      }
 +      return 0;
  }
  
  static int iuu_tiocmset(struct tty_struct *tty,
-@@ -1225,8 +1207,8 @@ static struct usb_serial_driver iuu_device = {
+@@ -1241,8 +1231,8 @@ static struct usb_serial_driver iuu_devi
        .tiocmset = iuu_tiocmset,
        .set_termios = iuu_set_termios,
        .init_termios = iuu_init_termios,