From: Pavel Skripkin <paskripkin@gmail.com>
To: mkl@pengutronix.de, yasushi.shoji@gmail.com, wg@grandegger.com
Cc: linux-can@vger.kernel.org, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, Pavel Skripkin <paskripkin@gmail.com>
Subject: [PATCH] net: can: add missing urb->transfer_dma initialization
Date: Sun, 25 Jul 2021 13:36:30 +0300 [thread overview]
Message-ID: <20210725103630.23864-1-paskripkin@gmail.com> (raw)
In-Reply-To: <20210725094246.pkdpvl5aaaftur3a@pengutronix.de>
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
next parent reply other threads:[~2021-07-25 10:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210725094246.pkdpvl5aaaftur3a@pengutronix.de>
2021-07-25 10:36 ` Pavel Skripkin [this message]
2021-07-25 13:27 ` [PATCH] net: can: add missing urb->transfer_dma initialization Yasushi SHOJI
2021-07-25 16:30 ` Marc Kleine-Budde
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=20210725103630.23864-1-paskripkin@gmail.com \
--to=paskripkin@gmail.com \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=wg@grandegger.com \
--cc=yasushi.shoji@gmail.com \
/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 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).