Skip to content

Commit d71e9b7

Browse files
Nadezda LutovinovaKelsey Skunberg
Nadezda Lutovinova
authored and
Kelsey Skunberg
committed
usb: gadget: mv_u3d: request_irq() after initializing UDC
BugLink: https://bugs.launchpad.net/bugs/1946024 [ Upstream commit 2af0c5f ] If IRQ occurs between calling request_irq() and mv_u3d_eps_init(), then null pointer dereference occurs since u3d->eps[] wasn't initialized yet but used in mv_u3d_nuke(). The patch puts registration of the interrupt handler after initializing of neccesery data. Found by Linux Driver Verification project (linuxtesting.org). Fixes: 90fccb5 ("usb: gadget: Gadget directory cleanup - group UDC drivers") Acked-by: Felipe Balbi <[email protected]> Signed-off-by: Nadezda Lutovinova <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Kamal Mostafa <[email protected]> Signed-off-by: Kelsey Skunberg <[email protected]>
1 parent e031731 commit d71e9b7

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

drivers/usb/gadget/udc/mv_u3d_core.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,14 +1922,6 @@ static int mv_u3d_probe(struct platform_device *dev)
19221922
goto err_get_irq;
19231923
}
19241924
u3d->irq = r->start;
1925-
if (request_irq(u3d->irq, mv_u3d_irq,
1926-
IRQF_SHARED, driver_name, u3d)) {
1927-
u3d->irq = 0;
1928-
dev_err(&dev->dev, "Request irq %d for u3d failed\n",
1929-
u3d->irq);
1930-
retval = -ENODEV;
1931-
goto err_request_irq;
1932-
}
19331925

19341926
/* initialize gadget structure */
19351927
u3d->gadget.ops = &mv_u3d_ops; /* usb_gadget_ops */
@@ -1942,6 +1934,15 @@ static int mv_u3d_probe(struct platform_device *dev)
19421934

19431935
mv_u3d_eps_init(u3d);
19441936

1937+
if (request_irq(u3d->irq, mv_u3d_irq,
1938+
IRQF_SHARED, driver_name, u3d)) {
1939+
u3d->irq = 0;
1940+
dev_err(&dev->dev, "Request irq %d for u3d failed\n",
1941+
u3d->irq);
1942+
retval = -ENODEV;
1943+
goto err_request_irq;
1944+
}
1945+
19451946
/* external vbus detection */
19461947
if (u3d->vbus) {
19471948
u3d->clock_gating = 1;
@@ -1965,8 +1966,8 @@ static int mv_u3d_probe(struct platform_device *dev)
19651966

19661967
err_unregister:
19671968
free_irq(u3d->irq, u3d);
1968-
err_request_irq:
19691969
err_get_irq:
1970+
err_request_irq:
19701971
kfree(u3d->status_req);
19711972
err_alloc_status_req:
19721973
kfree(u3d->eps);

0 commit comments

Comments
 (0)