Skip to content

Commit 2bef304

Browse files
alexdewargregkh
authored andcommitted
staging: emxx_udc: Fix passing of NULL to dma_alloc_coherent()
[ Upstream commit cc34073 ] 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: 33aa8d4 ("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> Link: https://lore.kernel.org/r/20200825091928.55794-1-alex.dewar90@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 7524142 commit 2bef304

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/staging/emxx_udc/emxx_udc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2593,7 +2593,7 @@ static int nbu2ss_ep_queue(struct usb_ep *_ep,
25932593

25942594
if (req->unaligned) {
25952595
if (!ep->virt_buf)
2596-
ep->virt_buf = dma_alloc_coherent(NULL, PAGE_SIZE,
2596+
ep->virt_buf = dma_alloc_coherent(udc->dev, PAGE_SIZE,
25972597
&ep->phys_buf,
25982598
GFP_ATOMIC | GFP_DMA);
25992599
if (ep->epnum > 0) {
@@ -3148,7 +3148,7 @@ static int nbu2ss_drv_remove(struct platform_device *pdev)
31483148
for (i = 0; i < NUM_ENDPOINTS; i++) {
31493149
ep = &udc->ep[i];
31503150
if (ep->virt_buf)
3151-
dma_free_coherent(NULL, PAGE_SIZE, (void *)ep->virt_buf,
3151+
dma_free_coherent(udc->dev, PAGE_SIZE, (void *)ep->virt_buf,
31523152
ep->phys_buf);
31533153
}
31543154

0 commit comments

Comments
 (0)