lkml.org 
[lkml]   [2006]   [Nov]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRe: [linux-usb-devel] [PATCH] usb: microtek possible memleak fix [second try]
Date
Hello, 

> > > Ist there a reason you are replacing at least somewhat descriptive labels
> > > with numbers?
> >
> > Yes.
> >
> > To me these numbers speak more than not really descriptive labels like
> > out_kfree out_kfree2 etc. I look at the code and see the flow. The most
> > important thing here is the order in which the resources are allocated and
> > if something goes wrong deallocated. Hence the numbers.
> >
> > Anyway if that's a problem I can rewrite it.
>
> Please do so, otherwise it's a good catch.

Ok. Second try.

Possible memleak fix on error path. The changes:

- out_kfree2 and out_free_urb replaced
- missing scsi_host_put() added

Here it goes:

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>

drivers/usb/image/microtek.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

--- linux-2.6.19-rc5-mm2-a/drivers/usb/image/microtek.c 2006-11-08 03:24:20.000000000 +0100
+++ linux-2.6.19-rc5-mm2-b/drivers/usb/image/microtek.c 2006-11-17 11:45:21.000000000 +0100
@@ -796,7 +796,7 @@ static int mts_usb_probe(struct usb_inte

new_desc->context.scsi_status = kmalloc(1, GFP_KERNEL);
if (!new_desc->context.scsi_status)
- goto out_kfree2;
+ goto out_free_urb;

new_desc->usb_dev = dev;
new_desc->usb_intf = intf;
@@ -822,18 +822,20 @@ static int mts_usb_probe(struct usb_inte
new_desc->host = scsi_host_alloc(&mts_scsi_host_template,
sizeof(new_desc));
if (!new_desc->host)
- goto out_free_urb;
+ goto out_kfree2;

new_desc->host->hostdata[0] = (unsigned long)new_desc;
if (scsi_add_host(new_desc->host, NULL)) {
err_retval = -EIO;
- goto out_free_urb;
+ goto out_host_put;
}
scsi_scan_host(new_desc->host);

usb_set_intfdata(intf, new_desc);
return 0;

+ out_host_put:
+ scsi_host_put(new_desc->host);
out_kfree2:
kfree(new_desc->context.scsi_status);
out_free_urb:

--
Regards,

Mariusz Kozlowski
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-11-17 11:57    [W:0.052 / U:0.844 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site