clear_halt_work
Roman Kagan
rkagan at mail.ru
Wed May 11 00:50:33 EDT 2005
On Tue, May 10, 2005 at 11:17:50PM +0200, Duncan Sands wrote:
> > Well, it's practically zero risk, but it improves readability and saves
> > a number of dereferences... I'm attaching it rediffed against the
> > current CVS, in case you change your mind :)
>
> OK, I applied it since it looks fine to me.
Thanks! There was one reference to transceivers which I had missed
because it was inside vdbg() and I didn't compile-test with DEBUG. I
went ahead and committed the fix myself as it was trivial.
> If you could fix up the
> deallocation and null dereference problems I mentioned, that would be
> great,
Thanks for spotting it! I was rushing for no good reason, as usual...
I've implemented your suggestions, it should be saner now. The patch is
below.
Cheers,
Roman.
Index: usbatm.c
===================================================================
RCS file: /home/cvs/usbatm/usbatm.c,v
retrieving revision 1.43
diff -u -p -r1.43 usbatm.c
--- usbatm.c 11 May 2005 04:28:06 -0000 1.43
+++ usbatm.c 11 May 2005 04:43:34 -0000
@@ -1036,13 +1036,6 @@ int usbatm_usb_probe(struct usb_interfac
struct usbatm_channel *channel = i < num_rcv_urbs ?
&instance->rx_channel : &instance->tx_channel;
- buffer = kmalloc(channel->buf_size, GFP_KERNEL);
- if (!buffer) {
- dev_dbg(dev, "%s: no memory for buffer %d!\n", __func__, i);
- goto fail_unbind;
- }
- memset(buffer, 0, channel->buf_size);
-
if (usb_pipeisoc(channel->endpoint)) {
/* don't expect iso out endpoints */
iso_size = usb_maxpacket(instance->usb_dev, channel->endpoint, 0);
@@ -1057,6 +1050,13 @@ int usbatm_usb_probe(struct usb_interfac
goto fail_unbind;
}
+ buffer = kmalloc(channel->buf_size, GFP_KERNEL);
+ if (!buffer) {
+ dev_dbg(dev, "%s: no memory for buffer %d!\n", __func__, i);
+ goto fail_unbind;
+ }
+ memset(buffer, 0, channel->buf_size);
+
usb_fill_bulk_urb(urb, instance->usb_dev, channel->endpoint,
buffer, channel->buf_size, usbatm_complete, channel);
if (iso_packets) {
@@ -1100,7 +1100,8 @@ int usbatm_usb_probe(struct usb_interfac
instance->driver->unbind(instance, intf);
fail_free:
for (i = 0; i < num_rcv_urbs + num_snd_urbs; i++) {
- kfree(instance->urbs[i]->transfer_buffer);
+ if (instance->urbs[i])
+ kfree(instance->urbs[i]->transfer_buffer);
usb_free_urb(instance->urbs[i]);
}
More information about the Usbatm
mailing list