Netdev Archive on lore.kernel.org help / color / mirror / Atom feed
* [PATCH] net: can: add missing urb->transfer_dma initialization [not found] <20210725094246.pkdpvl5aaaftur3a@pengutronix.de> @ 2021-07-25 10:36 ` Pavel Skripkin 2021-07-25 13:27 ` Yasushi SHOJI 0 siblings, 1 reply; 3+ messages in thread From: Pavel Skripkin @ 2021-07-25 10:36 UTC (permalink / raw) To: mkl, yasushi.shoji, wg; +Cc: linux-can, linux-kernel, netdev, Pavel Skripkin Yasushi reported, that his Microchip CAN Analyzer stopped working since commit 91c02557174b ("can: mcba_usb: fix memory leak in mcba_usb"). The problem was in missing urb->transfer_dma initialization. In my previous patch to this driver I refactored mcba_usb_start() code to avoid leaking usb coherent buffers. To achive it, I passed local stack variable to usb_alloc_coherent() and then saved it to private array to correctly free all coherent buffers on ->close() call. But I forgot to inialize urb->transfer_dma with variable passed to usb_alloc_coherent(). All of this was causing device to not work, since dma addr 0 is not valid and following log can be found on bug report page, which points exactly to problem described above. [ 33.862175] DMAR: [DMA Write] Request device [00:14.0] PASID ffffffff fault addr 0 [fault reason 05] PTE Write access is not set Bug report: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=990850 Reported-by: Yasushi SHOJI <yasushi.shoji@gmail.com> Fixes: 91c02557174b ("can: mcba_usb: fix memory leak in mcba_usb") Signed-off-by: Pavel Skripkin <paskripkin@gmail.com> --- drivers/net/can/usb/mcba_usb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/can/usb/mcba_usb.c b/drivers/net/can/usb/mcba_usb.c index a45865bd7254..a1a154c08b7f 100644 --- a/drivers/net/can/usb/mcba_usb.c +++ b/drivers/net/can/usb/mcba_usb.c @@ -653,6 +653,8 @@ static int mcba_usb_start(struct mcba_priv *priv) break; } + urb->transfer_dma = buf_dma; + usb_fill_bulk_urb(urb, priv->udev, usb_rcvbulkpipe(priv->udev, MCBA_USB_EP_IN), buf, MCBA_USB_RX_BUFF_SIZE, -- 2.32.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net: can: add missing urb->transfer_dma initialization 2021-07-25 10:36 ` [PATCH] net: can: add missing urb->transfer_dma initialization Pavel Skripkin @ 2021-07-25 13:27 ` Yasushi SHOJI 2021-07-25 16:30 ` Marc Kleine-Budde 0 siblings, 1 reply; 3+ messages in thread From: Yasushi SHOJI @ 2021-07-25 13:27 UTC (permalink / raw) To: Pavel Skripkin; +Cc: mkl, wg, linux-can, linux-kernel, netdev, Yasushi SHOJI Hi Pavel, I've tested this patch on top of v5.14-rc2. All good. Tested-by: Yasushi SHOJI <yashi@spacecubics.com> Some nitpicks. On Sun, Jul 25, 2021 at 7:36 PM Pavel Skripkin <paskripkin@gmail.com> wrote: > > Yasushi reported, that his Microchip CAN Analyzer stopped working since > commit 91c02557174b ("can: mcba_usb: fix memory leak in mcba_usb"). > The problem was in missing urb->transfer_dma initialization. > > In my previous patch to this driver I refactored mcba_usb_start() code to > avoid leaking usb coherent buffers. To achive it, I passed local stack achieve > variable to usb_alloc_coherent() and then saved it to private array to > correctly free all coherent buffers on ->close() call. But I forgot to > inialize urb->transfer_dma with variable passed to usb_alloc_coherent(). initialize > All of this was causing device to not work, since dma addr 0 is not valid > and following log can be found on bug report page, which points exactly to > problem described above. > > [ 33.862175] DMAR: [DMA Write] Request device [00:14.0] PASID ffffffff fault addr 0 [fault reason 05] PTE Write access is not set > > Bug report: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=990850 > > Reported-by: Yasushi SHOJI <yasushi.shoji@gmail.com> > Fixes: 91c02557174b ("can: mcba_usb: fix memory leak in mcba_usb") > Signed-off-by: Pavel Skripkin <paskripkin@gmail.com> > --- > drivers/net/can/usb/mcba_usb.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/net/can/usb/mcba_usb.c b/drivers/net/can/usb/mcba_usb.c > index a45865bd7254..a1a154c08b7f 100644 > --- a/drivers/net/can/usb/mcba_usb.c > +++ b/drivers/net/can/usb/mcba_usb.c > @@ -653,6 +653,8 @@ static int mcba_usb_start(struct mcba_priv *priv) > break; > } > > + urb->transfer_dma = buf_dma; > + > usb_fill_bulk_urb(urb, priv->udev, > usb_rcvbulkpipe(priv->udev, MCBA_USB_EP_IN), > buf, MCBA_USB_RX_BUFF_SIZE, > -- > 2.32.0 Pavel, thanks again for your quick fix. :-) Best, -- yashi ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: can: add missing urb->transfer_dma initialization 2021-07-25 13:27 ` Yasushi SHOJI @ 2021-07-25 16:30 ` Marc Kleine-Budde 0 siblings, 0 replies; 3+ messages in thread From: Marc Kleine-Budde @ 2021-07-25 16:30 UTC (permalink / raw) To: Yasushi SHOJI Cc: Pavel Skripkin, wg, linux-can, linux-kernel, netdev, Yasushi SHOJI [-- Attachment #1: Type: text/plain, Size: 1244 bytes --] On 25.07.2021 22:27:37, Yasushi SHOJI wrote: > Hi Pavel, > > I've tested this patch on top of v5.14-rc2. All good. > > Tested-by: Yasushi SHOJI <yashi@spacecubics.com> > > Some nitpicks. > > On Sun, Jul 25, 2021 at 7:36 PM Pavel Skripkin <paskripkin@gmail.com> wrote: > > > > Yasushi reported, that his Microchip CAN Analyzer stopped working since > > commit 91c02557174b ("can: mcba_usb: fix memory leak in mcba_usb"). > > The problem was in missing urb->transfer_dma initialization. > > > > In my previous patch to this driver I refactored mcba_usb_start() code to > > avoid leaking usb coherent buffers. To achive it, I passed local stack > > achieve > > > variable to usb_alloc_coherent() and then saved it to private array to > > correctly free all coherent buffers on ->close() call. But I forgot to > > inialize urb->transfer_dma with variable passed to usb_alloc_coherent(). > > initialize Fixed while applying. Thanks, Marc -- Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-07-25 16:30 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <20210725094246.pkdpvl5aaaftur3a@pengutronix.de> 2021-07-25 10:36 ` [PATCH] net: can: add missing urb->transfer_dma initialization Pavel Skripkin 2021-07-25 13:27 ` Yasushi SHOJI 2021-07-25 16:30 ` Marc Kleine-Budde
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).