* [PATCH] usb: gadget: udc: amd5536udc_pci fix crash if dma is used
@ 2021-03-13 19:20 Tong Zhang
2021-03-17 20:43 ` Greg Kroah-Hartman
0 siblings, 1 reply; 4+ messages in thread
From: Tong Zhang @ 2021-03-13 19:20 UTC (permalink / raw)
To: Felipe Balbi, Greg Kroah-Hartman, Lee Jones, Alexander A. Klimov,
Tong Zhang, linux-usb, linux-kernel
init_dma_pools() calls dma_pool_create(...dev->dev) to create dma pool.
however, dev->dev is actually set after calling init_dma_pools(), which
effectively makes dma_pool_create(..NULL) and cause crash.
To fix this issue, init dma only after dev->dev is set.
[ 1.317993] RIP: 0010:dma_pool_create+0x83/0x290
[ 1.323257] Call Trace:
[ 1.323390] ? pci_write_config_word+0x27/0x30
[ 1.323626] init_dma_pools+0x41/0x1a0 [snps_udc_core]
[ 1.323899] udc_pci_probe+0x202/0x2b1 [amd5536udc_pci]
Signed-off-by: Tong Zhang <ztong0001@gmail.com>
---
drivers/usb/gadget/udc/amd5536udc_pci.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/gadget/udc/amd5536udc_pci.c b/drivers/usb/gadget/udc/amd5536udc_pci.c
index 8d387e0e4d91..c80f9bd51b75 100644
--- a/drivers/usb/gadget/udc/amd5536udc_pci.c
+++ b/drivers/usb/gadget/udc/amd5536udc_pci.c
@@ -153,6 +153,11 @@ static int udc_pci_probe(
pci_set_master(pdev);
pci_try_set_mwi(pdev);
+ dev->phys_addr = resource;
+ dev->irq = pdev->irq;
+ dev->pdev = pdev;
+ dev->dev = &pdev->dev;
+
/* init dma pools */
if (use_dma) {
retval = init_dma_pools(dev);
@@ -160,11 +165,6 @@ static int udc_pci_probe(
goto err_dma;
}
- dev->phys_addr = resource;
- dev->irq = pdev->irq;
- dev->pdev = pdev;
- dev->dev = &pdev->dev;
-
/* general probing */
if (udc_probe(dev)) {
retval = -ENODEV;
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] usb: gadget: udc: amd5536udc_pci fix crash if dma is used
2021-03-13 19:20 [PATCH] usb: gadget: udc: amd5536udc_pci fix crash if dma is used Tong Zhang
@ 2021-03-17 20:43 ` Greg Kroah-Hartman
2021-03-17 23:04 ` [PATCH v2] usb: gadget: udc: amd5536udc_pci fix null-ptr-dereference Tong Zhang
2021-03-17 23:10 ` [PATCH] usb: gadget: udc: amd5536udc_pci fix crash if dma is used Tong Zhang
0 siblings, 2 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2021-03-17 20:43 UTC (permalink / raw)
To: Tong Zhang
Cc: Felipe Balbi, Lee Jones, Alexander A. Klimov, linux-usb, linux-kernel
On Sat, Mar 13, 2021 at 02:20:32PM -0500, Tong Zhang wrote:
> init_dma_pools() calls dma_pool_create(...dev->dev) to create dma pool.
> however, dev->dev is actually set after calling init_dma_pools(), which
> effectively makes dma_pool_create(..NULL) and cause crash.
> To fix this issue, init dma only after dev->dev is set.
>
> [ 1.317993] RIP: 0010:dma_pool_create+0x83/0x290
> [ 1.323257] Call Trace:
> [ 1.323390] ? pci_write_config_word+0x27/0x30
> [ 1.323626] init_dma_pools+0x41/0x1a0 [snps_udc_core]
> [ 1.323899] udc_pci_probe+0x202/0x2b1 [amd5536udc_pci]
>
> Signed-off-by: Tong Zhang <ztong0001@gmail.com>
What commit caused this problem?
Can you resend this with a "Fixes:" tag added showing that?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] usb: gadget: udc: amd5536udc_pci fix null-ptr-dereference
2021-03-17 20:43 ` Greg Kroah-Hartman
@ 2021-03-17 23:04 ` Tong Zhang
2021-03-17 23:10 ` [PATCH] usb: gadget: udc: amd5536udc_pci fix crash if dma is used Tong Zhang
1 sibling, 0 replies; 4+ messages in thread
From: Tong Zhang @ 2021-03-17 23:04 UTC (permalink / raw)
To: Felipe Balbi, Greg Kroah-Hartman, Alexander A. Klimov,
Tong Zhang, Lee Jones, Raviteja Garimella, linux-usb,
linux-kernel
init_dma_pools() calls dma_pool_create(...dev->dev) to create dma pool.
however, dev->dev is actually set after calling init_dma_pools(), which
effectively makes dma_pool_create(..NULL) and cause crash.
To fix this issue, init dma only after dev->dev is set.
[ 1.317993] RIP: 0010:dma_pool_create+0x83/0x290
[ 1.323257] Call Trace:
[ 1.323390] ? pci_write_config_word+0x27/0x30
[ 1.323626] init_dma_pools+0x41/0x1a0 [snps_udc_core]
[ 1.323899] udc_pci_probe+0x202/0x2b1 [amd5536udc_pci]
Fixes: 7c51247a1f62 (usb: gadget: udc: Provide correct arguments for 'dma_pool_create')
Signed-off-by: Tong Zhang <ztong0001@gmail.com>
---
v2: add Fixes tag and revise subject
drivers/usb/gadget/udc/amd5536udc_pci.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/gadget/udc/amd5536udc_pci.c b/drivers/usb/gadget/udc/amd5536udc_pci.c
index 8d387e0e4d91..c80f9bd51b75 100644
--- a/drivers/usb/gadget/udc/amd5536udc_pci.c
+++ b/drivers/usb/gadget/udc/amd5536udc_pci.c
@@ -153,6 +153,11 @@ static int udc_pci_probe(
pci_set_master(pdev);
pci_try_set_mwi(pdev);
+ dev->phys_addr = resource;
+ dev->irq = pdev->irq;
+ dev->pdev = pdev;
+ dev->dev = &pdev->dev;
+
/* init dma pools */
if (use_dma) {
retval = init_dma_pools(dev);
@@ -160,11 +165,6 @@ static int udc_pci_probe(
goto err_dma;
}
- dev->phys_addr = resource;
- dev->irq = pdev->irq;
- dev->pdev = pdev;
- dev->dev = &pdev->dev;
-
/* general probing */
if (udc_probe(dev)) {
retval = -ENODEV;
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] usb: gadget: udc: amd5536udc_pci fix crash if dma is used
2021-03-17 20:43 ` Greg Kroah-Hartman
2021-03-17 23:04 ` [PATCH v2] usb: gadget: udc: amd5536udc_pci fix null-ptr-dereference Tong Zhang
@ 2021-03-17 23:10 ` Tong Zhang
1 sibling, 0 replies; 4+ messages in thread
From: Tong Zhang @ 2021-03-17 23:10 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Felipe Balbi, Lee Jones, Alexander A. Klimov, linux-usb, open list
Hi Greg,
Thanks for the comments.
I tried to find the commit that introduced the use of dev->dev in
init_dma_pools()
and added that commit to the Fixes tag in v2 patch.
Please see if this one works.
Thanks,
- Tong
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-03-17 23:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-13 19:20 [PATCH] usb: gadget: udc: amd5536udc_pci fix crash if dma is used Tong Zhang
2021-03-17 20:43 ` Greg Kroah-Hartman
2021-03-17 23:04 ` [PATCH v2] usb: gadget: udc: amd5536udc_pci fix null-ptr-dereference Tong Zhang
2021-03-17 23:10 ` [PATCH] usb: gadget: udc: amd5536udc_pci fix crash if dma is used Tong Zhang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.