All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bernd Krumboeck <krumboeck@universalnet.at>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: linux-can@vger.kernel.org, linux-usb@vger.kernel.org,
	info@gerhard-bertelsmann.de, gediminas@8devices.com
Subject: Re: [PATCH v3] usb_8dev: Add support for USB2CAN interface from 8 devices
Date: Thu, 06 Dec 2012 05:47:52 +0100	[thread overview]
Message-ID: <50C02378.90001@universalnet.at> (raw)
In-Reply-To: <50BE6F0E.80308@pengutronix.de>

Hi Marc!


Am 2012-12-04 22:45, schrieb Marc Kleine-Budde:
>> +
>> +        /* create a URB, and a buffer for it */
>> +        urb = usb_alloc_urb(0, GFP_KERNEL);
>> +        if (!urb) {
>> +            netdev_err(netdev, "No memory left for URBs\n");
>> +            return -ENOMEM;
>
> who will free the already allocated urbs if i != 0 ?

This function tries to submit 10 urbs (MAX_RX_URBS) for receiving. When we could not
submit all, we still proceed as long as we could submit at least 1.

We must not free, because we should break the loop not return from the function.
I'll correct.


>
>> +        }
>> +
>> +        buf = usb_alloc_coherent(dev->udev, RX_BUFFER_SIZE, GFP_KERNEL,
>> +                     &urb->transfer_dma);
>> +        if (!buf) {
>> +            netdev_err(netdev, "No memory left for USB buffer\n");
>> +            usb_free_urb(urb);
>
> same problem here for coherent

dito.

>
>> +            return -ENOMEM;
>> +        }
>> +
>> +        usb_fill_bulk_urb(urb, dev->udev,
>> +                  usb_rcvbulkpipe(dev->udev,
>> +                          USB_8DEV_ENDP_DATA_RX),
>> +                  buf, RX_BUFFER_SIZE,
>> +                  usb_8dev_read_bulk_callback, dev);
>> +        urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
>> +        usb_anchor_urb(urb, &dev->rx_submitted);
>> +
>> +        err = usb_submit_urb(urb, GFP_KERNEL);
>> +        if (err) {
>> +            if (err == -ENODEV)
>> +                netif_device_detach(dev->netdev);
>> +
>> +            usb_unanchor_urb(urb);
>> +            usb_free_coherent(dev->udev, RX_BUFFER_SIZE, buf,
>> +                      urb->transfer_dma);
> same here
>
> add a loop that runs backwards at the end of the function

dito.

>
>> +            break;
>> +        }
>> +
>> +        /* Drop reference, USB core will take care of freeing it */
>> +        usb_free_urb(urb);
>> +    }
>> +
>> +    /* Did we submit any URBs */
>> +    if (i == 0) {
>> +        netdev_warn(netdev, "couldn't setup read URBs\n");
>> +        return err;
>> +    }
>> +
>
> Marc
>

regards,
Bernd

      parent reply	other threads:[~2012-12-06  4:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-04 20:44 [PATCH v3] usb_8dev: Add support for USB2CAN interface from 8 devices krumboeck
2012-12-04 20:44 ` Wolfgang Grandegger
     [not found]   ` <50BE60AD.10307-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2012-12-04 22:20     ` Bernd Krumboeck
2012-12-05  7:24       ` Wolfgang Grandegger
2012-12-04 21:45 ` Marc Kleine-Budde
2012-12-05 17:36   ` Bernd Krumboeck
     [not found]     ` <50BF8602.1070909-Hi41barv6paIERSsAYjmKA@public.gmane.org>
2012-12-05 21:40       ` Marc Kleine-Budde
     [not found]         ` <50BFBF60.2090106-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-12-06  4:28           ` Bernd Krumboeck
2012-12-06  4:47   ` Bernd Krumboeck [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50C02378.90001@universalnet.at \
    --to=krumboeck@universalnet.at \
    --cc=gediminas@8devices.com \
    --cc=info@gerhard-bertelsmann.de \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.