This patchset resolves a to memory leak which can occur with successive iterations of calling gs_can_open() and gs_can_close(). The central cause of this memory leak, which is an issue common to many of the USB CAN drivers, is that memory allocated for RX buffers using usb_alloc_coherent() and then kept in the URB will be properly freed when the URB is killed. This assumption is incorrect, as memory allocated with usb_alloc_coherent() must be freed with usb_free_coherent(), and there is no provision for this in the existing URB code. The common solution to this, found in v1 of my patches as well as in already merged patches for other CAN USB drivers (see the patch for the esd CAN-USB/2 driver here: https://www.spinics.net/lists/linux-can/msg08203.html) is for the driver itself to maintain an array of addresses of the buffers allocated with usb_alloc_coherent() and to then iteratively call usb_free_coherent() on them in their close function. This solution requires a driver developer to understand this unclear nuance, and it has historically been solved in a piecemeal way one driver at a time (note: the gs_usb driver has had this issue since the 3.x.x kernel series). Rather than continue to place the burden of complexity on the drivers, this patchset adds a new URB flag which allows the DMA buffer to be correctly freed with the URB is killed. This results in a much simpler solution at the driver level and with minimal additional code in the USB core. ** Changelog ** v2 -> v3: * Resolve style nits in gs_usb.c * Squash commits in urb.c and correct authorship v1 -> v2: * Add URB_FREE_COHERENT flag to urb.c * Use URB_FREE_COHERENT flag rather than arrays of buffers in gs_usb.c Rhett Aultman (1): can: gs_usb: fix DMA memory leak on close Vincent Mailhol (1): drivers: usb/core/urb: Add URB_FREE_COHERENT drivers/net/can/usb/gs_usb.c | 2 +- drivers/usb/core/urb.c | 5 ++++- include/linux/usb.h | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) -- 2.30.2