LKML Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 2/2] USB(u_serial.c): it has a NULL point
@ 2019-11-03  2:44 hui yang
  2019-11-03 12:42 ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: hui yang @ 2019-11-03  2:44 UTC (permalink / raw)
  To: balbi; +Cc: gregkh, mirq-linux, linux-usb, linux-kernel, YangHui

From: YangHui <yanghui.def@gmail.com>

Unable to handle kernel NULL pointer dereference at virtual address 000002a0
Kernel BUG at tty_wakeup+0x18/0x8c
[<0000000095135e9d>] tty_wakeup+0x18/0x8c
[<00000000c35f19e4>] gs_start_io+0xc8/0x158
[<00000000b11b184e>] gserial_connect+0xd0/0x174
[<00000000642201de>] acm_set_alt+0x70/0x180
[<00000000a9d38e8b>] composite_setup+0x1848/0x1a7c
[<0000000072c88781>] android_setup+0x1ec/0x1f4
[<000000004c0127a5>] msm_udc_irq+0x8d0/0xc0c
[<00000000f8bb9acf>] __handle_irq_event_percpu+0x74/0x294
[<00000000afd57256>] handle_irq_event+0x60/0xc8
[<0000000076719b24>] handle_fasteoi_irq+0xc8/0x1c4
[<00000000421f3d87>] generic_handle_irq+0x34/0x4c
[<00000000b2f2d343>] __handle_domain_irq+0x6c/0xbc
[<00000000c74325e8>] gic_handle_irq+0x6c/0xe0
yes,we can see the port->port.tty==NULL, so system crashed

Signed-off-by: YangHui <yanghui.def@gmail.com>
---
 drivers/usb/gadget/function/u_serial.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
index 65f634e..a1c2ac2 100644
--- a/drivers/usb/gadget/function/u_serial.c
+++ b/drivers/usb/gadget/function/u_serial.c
@@ -562,6 +562,8 @@ static int gs_start_io(struct gs_port *port)
 
 	/* unblock any pending writes into our circular buffer */
 	if (started) {
+		if (port->port.tty == NULL)
+			return -EIO;
 		tty_wakeup(port->port.tty);
 	} else {
 		gs_free_requests(ep, head, &port->read_allocated);
-- 
2.7.4


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] USB(u_serial.c): it has a NULL point
  2019-11-03  2:44 [PATCH 2/2] USB(u_serial.c): it has a NULL point hui yang
@ 2019-11-03 12:42 ` Greg KH
  2019-11-09  7:49   ` hui yang
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2019-11-03 12:42 UTC (permalink / raw)
  To: hui yang; +Cc: balbi, mirq-linux, linux-usb, linux-kernel

On Sun, Nov 03, 2019 at 10:44:04AM +0800, hui yang wrote:
> From: YangHui <yanghui.def@gmail.com>
> 
> Unable to handle kernel NULL pointer dereference at virtual address 000002a0
> Kernel BUG at tty_wakeup+0x18/0x8c
> [<0000000095135e9d>] tty_wakeup+0x18/0x8c
> [<00000000c35f19e4>] gs_start_io+0xc8/0x158
> [<00000000b11b184e>] gserial_connect+0xd0/0x174
> [<00000000642201de>] acm_set_alt+0x70/0x180
> [<00000000a9d38e8b>] composite_setup+0x1848/0x1a7c
> [<0000000072c88781>] android_setup+0x1ec/0x1f4
> [<000000004c0127a5>] msm_udc_irq+0x8d0/0xc0c
> [<00000000f8bb9acf>] __handle_irq_event_percpu+0x74/0x294
> [<00000000afd57256>] handle_irq_event+0x60/0xc8
> [<0000000076719b24>] handle_fasteoi_irq+0xc8/0x1c4
> [<00000000421f3d87>] generic_handle_irq+0x34/0x4c
> [<00000000b2f2d343>] __handle_domain_irq+0x6c/0xbc
> [<00000000c74325e8>] gic_handle_irq+0x6c/0xe0
> yes,we can see the port->port.tty==NULL, so system crashed
> 
> Signed-off-by: YangHui <yanghui.def@gmail.com>
> ---
>  drivers/usb/gadget/function/u_serial.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
> index 65f634e..a1c2ac2 100644
> --- a/drivers/usb/gadget/function/u_serial.c
> +++ b/drivers/usb/gadget/function/u_serial.c
> @@ -562,6 +562,8 @@ static int gs_start_io(struct gs_port *port)
>  
>  	/* unblock any pending writes into our circular buffer */
>  	if (started) {
> +		if (port->port.tty == NULL)
> +			return -EIO;

How can this happen?  Shouldn't this be handled earlier?

If not, can you document this how this can be true and what should be
done about it?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] USB(u_serial.c): it has a NULL point
  2019-11-03 12:42 ` Greg KH
@ 2019-11-09  7:49   ` hui yang
  2019-11-13  7:13     ` Peter Chen
  0 siblings, 1 reply; 5+ messages in thread
From: hui yang @ 2019-11-09  7:49 UTC (permalink / raw)
  To: Greg KH; +Cc: balbi, mirq-linux, linux-usb, linux-kernel

I'm sorry for my fault . Now I send to everyone .

When we use USB to transmit data
with PC, the phone will crashed Low probability .
We found port->port.tty became NULL.

Thanks

Greg KH <gregkh@linuxfoundation.org> 于2019年11月3日周日 下午8:42写道:
>
> On Sun, Nov 03, 2019 at 10:44:04AM +0800, hui yang wrote:
> > From: YangHui <yanghui.def@gmail.com>
> >
> > Unable to handle kernel NULL pointer dereference at virtual address 000002a0
> > Kernel BUG at tty_wakeup+0x18/0x8c
> > [<0000000095135e9d>] tty_wakeup+0x18/0x8c
> > [<00000000c35f19e4>] gs_start_io+0xc8/0x158
> > [<00000000b11b184e>] gserial_connect+0xd0/0x174
> > [<00000000642201de>] acm_set_alt+0x70/0x180
> > [<00000000a9d38e8b>] composite_setup+0x1848/0x1a7c
> > [<0000000072c88781>] android_setup+0x1ec/0x1f4
> > [<000000004c0127a5>] msm_udc_irq+0x8d0/0xc0c
> > [<00000000f8bb9acf>] __handle_irq_event_percpu+0x74/0x294
> > [<00000000afd57256>] handle_irq_event+0x60/0xc8
> > [<0000000076719b24>] handle_fasteoi_irq+0xc8/0x1c4
> > [<00000000421f3d87>] generic_handle_irq+0x34/0x4c
> > [<00000000b2f2d343>] __handle_domain_irq+0x6c/0xbc
> > [<00000000c74325e8>] gic_handle_irq+0x6c/0xe0
> > yes,we can see the port->port.tty==NULL, so system crashed
> >
> > Signed-off-by: YangHui <yanghui.def@gmail.com>
> > ---
> >  drivers/usb/gadget/function/u_serial.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
> > index 65f634e..a1c2ac2 100644
> > --- a/drivers/usb/gadget/function/u_serial.c
> > +++ b/drivers/usb/gadget/function/u_serial.c
> > @@ -562,6 +562,8 @@ static int gs_start_io(struct gs_port *port)
> >
> >       /* unblock any pending writes into our circular buffer */
> >       if (started) {
> > +             if (port->port.tty == NULL)
> > +                     return -EIO;
>
> How can this happen?  Shouldn't this be handled earlier?
>
> If not, can you document this how this can be true and what should be
> done about it?
>
> thanks,
>
> greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] USB(u_serial.c): it has a NULL point
  2019-11-09  7:49   ` hui yang
@ 2019-11-13  7:13     ` Peter Chen
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Chen @ 2019-11-13  7:13 UTC (permalink / raw)
  To: hui yang; +Cc: Greg KH, balbi, mirq-linux, linux-usb, linux-kernel

On 19-11-09 15:49:13, hui yang wrote:
> I'm sorry for my fault . Now I send to everyone .
> 
> When we use USB to transmit data
> with PC, the phone will crashed Low probability .
> We found port->port.tty became NULL.

Would you please debug more, it seems gs open/close (gs_open/gs_close)
are something wrong. The value port->port.tty and port->port.count
are inconsistent.

Peter

> 
> Thanks
> 
> Greg KH <gregkh@linuxfoundation.org> 于2019年11月3日周日 下午8:42写道:
> >
> > On Sun, Nov 03, 2019 at 10:44:04AM +0800, hui yang wrote:
> > > From: YangHui <yanghui.def@gmail.com>
> > >
> > > Unable to handle kernel NULL pointer dereference at virtual address 000002a0
> > > Kernel BUG at tty_wakeup+0x18/0x8c
> > > [<0000000095135e9d>] tty_wakeup+0x18/0x8c
> > > [<00000000c35f19e4>] gs_start_io+0xc8/0x158
> > > [<00000000b11b184e>] gserial_connect+0xd0/0x174
> > > [<00000000642201de>] acm_set_alt+0x70/0x180
> > > [<00000000a9d38e8b>] composite_setup+0x1848/0x1a7c
> > > [<0000000072c88781>] android_setup+0x1ec/0x1f4
> > > [<000000004c0127a5>] msm_udc_irq+0x8d0/0xc0c
> > > [<00000000f8bb9acf>] __handle_irq_event_percpu+0x74/0x294
> > > [<00000000afd57256>] handle_irq_event+0x60/0xc8
> > > [<0000000076719b24>] handle_fasteoi_irq+0xc8/0x1c4
> > > [<00000000421f3d87>] generic_handle_irq+0x34/0x4c
> > > [<00000000b2f2d343>] __handle_domain_irq+0x6c/0xbc
> > > [<00000000c74325e8>] gic_handle_irq+0x6c/0xe0
> > > yes,we can see the port->port.tty==NULL, so system crashed
> > >
> > > Signed-off-by: YangHui <yanghui.def@gmail.com>
> > > ---
> > >  drivers/usb/gadget/function/u_serial.c | 2 ++
> > >  1 file changed, 2 insertions(+)
> > >
> > > diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
> > > index 65f634e..a1c2ac2 100644
> > > --- a/drivers/usb/gadget/function/u_serial.c
> > > +++ b/drivers/usb/gadget/function/u_serial.c
> > > @@ -562,6 +562,8 @@ static int gs_start_io(struct gs_port *port)
> > >
> > >       /* unblock any pending writes into our circular buffer */
> > >       if (started) {
> > > +             if (port->port.tty == NULL)
> > > +                     return -EIO;
> >
> > How can this happen?  Shouldn't this be handled earlier?
> >
> > If not, can you document this how this can be true and what should be
> > done about it?
> >
> > thanks,
> >
> > greg k-h

-- 

Thanks,
Peter Chen

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] USB(u_serial.c): it has a NULL point
       [not found] <5dbeddab.1c69fb81.244fa.5f8c@mx.google.com>
@ 2019-11-03 14:16 ` Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2019-11-03 14:16 UTC (permalink / raw)
  To: yanghui.def; +Cc: linux-kernel, mirq-linux, balbi, linux-usb

On Sun, Nov 03, 2019 at 10:01:11PM +0800, yanghui.def@gmail.com wrote:

html email is deleted by the list :(

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-03  2:44 [PATCH 2/2] USB(u_serial.c): it has a NULL point hui yang
2019-11-03 12:42 ` Greg KH
2019-11-09  7:49   ` hui yang
2019-11-13  7:13     ` Peter Chen
     [not found] <5dbeddab.1c69fb81.244fa.5f8c@mx.google.com>
2019-11-03 14:16 ` Greg KH

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git