Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=fe4b65ec9127a336eeaa503f878062d9e6f44591
Commit:     fe4b65ec9127a336eeaa503f878062d9e6f44591
Parent:     7378c57a8d4cf36e2f2b389d96d0d85043bd1c17
Author:     Oliver Neukum <[EMAIL PROTECTED]>
AuthorDate: Wed Mar 14 15:22:25 2007 +0100
Committer:  Greg Kroah-Hartman <[EMAIL PROTECTED]>
CommitDate: Fri Apr 27 13:28:35 2007 -0700

    mos7720 update
    
    this driver has an interesting way of handling ENOMEM: complain and ignore.
    If you decide to live with allocation failures, you must
    
    1. guard against URBs without corresponding buffers
    2. complete allocation failures
    3. always test entries for NULL before you follow the pointers
    
    This patch does so.
    
    Signed-off-by: Oliver Neukum <[EMAIL PROTECTED]>
    Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>
---
 drivers/usb/serial/mos7720.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 4538dc3..6ba87e6 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -333,6 +333,7 @@ static int mos7720_open(struct usb_serial_port *port, 
struct file * filp)
        int response;
        int port_number;
        char data;
+       int allocated_urbs = 0;
        int j;
 
        serial = port->serial;
@@ -365,10 +366,16 @@ static int mos7720_open(struct usb_serial_port *port, 
struct file * filp)
                                               GFP_KERNEL);
                if (!urb->transfer_buffer) {
                        err("%s-out of memory for urb buffers.", __FUNCTION__);
+                       usb_free_urb(mos7720_port->write_urb_pool[j]);
+                       mos7720_port->write_urb_pool[j] = NULL;
                        continue;
                }
+               allocated_urbs++;
        }
 
+       if (!allocated_urbs)
+               return -ENOMEM;
+
         /* Initialize MCS7720 -- Write Init values to corresponding Registers
          *
          * Register Index
@@ -526,7 +533,7 @@ static int mos7720_chars_in_buffer(struct usb_serial_port 
*port)
        }
 
        for (i = 0; i < NUM_URBS; ++i) {
-               if (mos7720_port->write_urb_pool[i]->status == -EINPROGRESS)
+               if (mos7720_port->write_urb_pool[i] && 
mos7720_port->write_urb_pool[i]->status == -EINPROGRESS)
                        chars += URB_TRANSFER_BUFFER_SIZE;
        }
        dbg("%s - returns %d", __FUNCTION__, chars);
@@ -629,7 +636,7 @@ static int mos7720_write_room(struct usb_serial_port *port)
        }
 
        for (i = 0; i < NUM_URBS; ++i) {
-               if (mos7720_port->write_urb_pool[i]->status != -EINPROGRESS)
+               if (mos7720_port->write_urb_pool[i] && 
mos7720_port->write_urb_pool[i]->status != -EINPROGRESS)
                        room += URB_TRANSFER_BUFFER_SIZE;
        }
 
@@ -664,7 +671,7 @@ static int mos7720_write(struct usb_serial_port *port,
        urb = NULL;
 
        for (i = 0; i < NUM_URBS; ++i) {
-               if (mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) {
+               if (mos7720_port->write_urb_pool[i] && 
mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) {
                        urb = mos7720_port->write_urb_pool[i];
                        dbg("URB:%d",i);
                        break;
-
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