linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Dewar <alex.dewar90@gmail.com>
To: dan.carpenter@oracle.com
Cc: alex.dewar90@gmail.com, damm+renesas@opensource.se,
	devel@driverdev.osuosl.org, frank@generalsoftwareinc.com,
	gregkh@linuxfoundation.org, horms+renesas@verge.net.au,
	jarias.linux@gmail.com, linux-kernel@vger.kernel.org,
	saiyamdoshi.in@gmail.com, yuehaibing@huawei.com
Subject: [PATCH v2] staging: emxx_udc: Fix passing of NULL to dma_alloc_coherent()
Date: Tue, 25 Aug 2020 10:19:28 +0100	[thread overview]
Message-ID: <20200825091928.55794-1-alex.dewar90@gmail.com> (raw)
In-Reply-To: <20200825082846.GR5493@kadam>

In nbu2ss_eq_queue() memory is allocated with dma_alloc_coherent(),
though, strangely, NULL is passed as the struct device* argument. Pass
the UDC's device instead. Fix up the corresponding call to
dma_free_coherent() in the same way.

Build-tested on x86 only.

Fixes: 33aa8d45a4fe ("staging: emxx_udc: Add Emma Mobile USB Gadget driver")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
---
v2: also fix call to dma_free_coherent() (Dan)

@Magnus: I noticed you contributed this code back in 2014... I don't
suppose you happen to have the hardware lying around to test this so we
can get a Tested-by....? :)
---
 drivers/staging/emxx_udc/emxx_udc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c
index 03929b9d3a8bc..d0725bc8b48a4 100644
--- a/drivers/staging/emxx_udc/emxx_udc.c
+++ b/drivers/staging/emxx_udc/emxx_udc.c
@@ -2593,7 +2593,7 @@ static int nbu2ss_ep_queue(struct usb_ep *_ep,
 
 	if (req->unaligned) {
 		if (!ep->virt_buf)
-			ep->virt_buf = dma_alloc_coherent(NULL, PAGE_SIZE,
+			ep->virt_buf = dma_alloc_coherent(udc->dev, PAGE_SIZE,
 							  &ep->phys_buf,
 							  GFP_ATOMIC | GFP_DMA);
 		if (ep->epnum > 0)  {
@@ -3148,7 +3148,7 @@ static int nbu2ss_drv_remove(struct platform_device *pdev)
 	for (i = 0; i < NUM_ENDPOINTS; i++) {
 		ep = &udc->ep[i];
 		if (ep->virt_buf)
-			dma_free_coherent(NULL, PAGE_SIZE, (void *)ep->virt_buf,
+			dma_free_coherent(udc->dev, PAGE_SIZE, (void *)ep->virt_buf,
 					  ep->phys_buf);
 	}
 
-- 
2.28.0


      reply	other threads:[~2020-08-25  9:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200824142118.GA223827@mwanda>
2020-08-24 15:19 ` [PATCH] staging: emxx_udc: Fix passing of NULL to dma_alloc_coherent() Alex Dewar
2020-08-24 15:57   ` Alex Dewar
2020-08-25  7:37     ` Dan Carpenter
2020-08-25  8:14       ` Alex Dewar
2020-08-25  8:28         ` Dan Carpenter
2020-08-25  9:19           ` Alex Dewar [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=20200825091928.55794-1-alex.dewar90@gmail.com \
    --to=alex.dewar90@gmail.com \
    --cc=damm+renesas@opensource.se \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=frank@generalsoftwareinc.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=horms+renesas@verge.net.au \
    --cc=jarias.linux@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=saiyamdoshi.in@gmail.com \
    --cc=yuehaibing@huawei.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).