From: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>
To: Marek Szyprowski <m.szyprowski@samsung.com>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-samsung-soc@vger.kernel.org"
<linux-samsung-soc@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: Alan Stern <stern@rowland.harvard.edu>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH] usb: dwc2: gadget: don't reset gadget's driver->bus
Date: Fri, 13 May 2022 07:18:19 +0000 [thread overview]
Message-ID: <40bf9f88-ec75-4049-412c-fd489c384205@synopsys.com> (raw)
In-Reply-To: <20220505104618.22729-1-m.szyprowski@samsung.com>
On 5/5/2022 2:46 PM, Marek Szyprowski wrote:
> UDC driver should not touch gadget's driver internals, especially it
> should not reset driver->bus. This wasn't harmful so far, but since
> commit fc274c1e9973 ("USB: gadget: Add a new bus for gadgets") gadget
> subsystem got it's own bus and messing with ->bus triggers the
> following NULL pointer dereference:
>
> dwc2 12480000.hsotg: bound driver g_ether
> 8<--- cut here ---
> Unable to handle kernel NULL pointer dereference at virtual address 00000000
> [00000000] *pgd=00000000
> Internal error: Oops: 5 [#1] SMP ARM
> Modules linked in: ...
> CPU: 0 PID: 620 Comm: modprobe Not tainted 5.18.0-rc5-next-20220504 #11862
> Hardware name: Samsung Exynos (Flattened Device Tree)
> PC is at module_add_driver+0x44/0xe8
> LR is at sysfs_do_create_link_sd+0x84/0xe0
> ...
> Process modprobe (pid: 620, stack limit = 0x(ptrval))
> ...
> module_add_driver from bus_add_driver+0xf4/0x1e4
> bus_add_driver from driver_register+0x78/0x10c
> driver_register from usb_gadget_register_driver_owner+0x40/0xb4
> usb_gadget_register_driver_owner from do_one_initcall+0x44/0x1e0
> do_one_initcall from do_init_module+0x44/0x1c8
> do_init_module from load_module+0x19b8/0x1b9c
> load_module from sys_finit_module+0xdc/0xfc
> sys_finit_module from ret_fast_syscall+0x0/0x54
> Exception stack(0xf1771fa8 to 0xf1771ff0)
> ...
> dwc2 12480000.hsotg: new device is high-speed
> ---[ end trace 0000000000000000 ]---
>
> Fix this by removing driver->bus entry reset.
>
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: Minas Harutyunyan <hminas@synopsys.com>
> ---
> drivers/usb/dwc2/gadget.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> index eee3504397e6..fe2a58c75861 100644
> --- a/drivers/usb/dwc2/gadget.c
> +++ b/drivers/usb/dwc2/gadget.c
> @@ -4544,7 +4544,6 @@ static int dwc2_hsotg_udc_start(struct usb_gadget *gadget,
>
> WARN_ON(hsotg->driver);
>
> - driver->driver.bus = NULL;
> hsotg->driver = driver;
> hsotg->gadget.dev.of_node = hsotg->dev->of_node;
> hsotg->gadget.speed = USB_SPEED_UNKNOWN;
prev parent reply other threads:[~2022-05-13 7:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20220505104630eucas1p1e3797aef5ed7f54f861bf3622b542713@eucas1p1.samsung.com>
2022-05-05 10:46 ` [PATCH] usb: dwc2: gadget: don't reset gadget's driver->bus Marek Szyprowski
2022-05-13 7:18 ` Minas Harutyunyan [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=40bf9f88-ec75-4049-412c-fd489c384205@synopsys.com \
--to=minas.harutyunyan@synopsys.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=stern@rowland.harvard.edu \
/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).