Feedbacks are wellcome

... why don't return -ENOMEM on mem. allocation failure in usblp_probe?



diff -urN 1.0/drivers/usb/class/usblp.c 1.1/drivers/usb/class/usblp.c
--- 1.0/drivers/usb/class/usblp.c       2003-07-25 22:00:19.000000000 +0200
+++ 1.1/drivers/usb/class/usblp.c       2003-07-25 23:07:47.000000000 +0200
@@ -27,6 +27,8 @@
  *     v0.12 - add hpoj.sourceforge.net ioctls (David Paschal)
  *     v0.13 - alloc space for statusbuf (<status> not on stack);
  *             use usb_buffer_alloc() for read buf & write buf;
+ *      v0.14 - minor cleanups and better handling of failure in
+ *              usblp_probe. Daniele Bellucci <[EMAIL PROTECTED]>
  */
 
 /*
@@ -60,7 +62,7 @@
 /*
  * Version Information
  */
-#define DRIVER_VERSION "v0.13"
+#define DRIVER_VERSION "v0.14"
 #define DRIVER_AUTHOR "Michael Gee, Pavel Machek, Vojtech Pavlik, Randy Dunlap, Pete 
Zaitcev, David Paschal"
 #define DRIVER_DESC "USB Printer Device Class driver"
 
@@ -851,19 +853,18 @@
                goto abort;
        }
 
-       usblp->writebuf = usblp->readbuf = NULL;
        usblp->writeurb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
        usblp->readurb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
        /* Malloc write & read buffers.  We somewhat wastefully
         * malloc both regardless of bidirectionality, because the
         * alternate setting can be changed later via an ioctl. */
        if (!(usblp->writebuf = usb_buffer_alloc(dev, USBLP_BUF_SIZE,
-                               GFP_KERNEL, &usblp->writeurb->transfer_dma))) {
+                                                GFP_KERNEL, 
&usblp->writeurb->transfer_dma))) {
                err("out of memory for write buf");
                goto abort;
        }
        if (!(usblp->readbuf = usb_buffer_alloc(dev, USBLP_BUF_SIZE,
-                               GFP_KERNEL, &usblp->readurb->transfer_dma))) {
+                                               GFP_KERNEL, 
&usblp->readurb->transfer_dma))) {
                err("out of memory for read buf");
                goto abort;
        }
@@ -927,14 +928,18 @@
        if (usblp) {
                if (usblp->writebuf)
                        usb_buffer_free (usblp->dev, USBLP_BUF_SIZE,
-                               usblp->writebuf, usblp->writeurb->transfer_dma);
+                                        usblp->writebuf, 
usblp->writeurb->transfer_dma);
                if (usblp->readbuf)
                        usb_buffer_free (usblp->dev, USBLP_BUF_SIZE,
-                               usblp->readbuf, usblp->writeurb->transfer_dma);
-               kfree(usblp->statusbuf);
-               kfree(usblp->device_id_string);
-               usb_free_urb(usblp->writeurb);
-               usb_free_urb(usblp->readurb);
+                                        usblp->readbuf, 
usblp->writeurb->transfer_dma);
+               if (usblp->statusbuf)
+                       kfree(usblp->statusbuf);
+               if (usblp->device_id_string)
+                       kfree(usblp->device_id_string);
+               if (usblp->writeurb)
+                       usb_free_urb(usblp->writeurb);
+               if (usblp->readurb)
+                       usb_free_urb(usblp->readurb);
                kfree(usblp);
        }
        return -EIO;



Daniele.







-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to