Re: [RFC PATCH 3/3] usbnet: Fix memory leak when rx_submit() fails
From: BjÃrn Mork
Date: Tue Sep 19 2017 - 13:41:24 EST
Douglas Anderson <dianders@xxxxxxxxxxxx> writes:
> If rx_submit() returns an error code then nobody calls usb_free_urb().
> That means it's leaked.
Nope. rx_submit() will call usb_free_urb() before returning an error:
static int rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
..
if (!skb) {
netif_dbg(dev, rx_err, dev->net, "no rx skb\n");
usbnet_defer_kevent (dev, EVENT_RX_MEMORY);
usb_free_urb (urb);
return -ENOMEM;
}
..
if (retval) {
dev_kfree_skb_any (skb);
usb_free_urb (urb);
}
BjÃrn