On Wed, Nov 16, 2016 at 09:46:29PM +0100, Felix Hädicke wrote: > Add check for NULL before calling kthread_stop(). > > There were cases in which gserial_console_exit() was called, but the > console thread was not started. This resulted in an invalid > kthread_stop(NULL) call. You can add oops dump in log. > > Signed-off-by: Felix Hädicke <felixhaedicke@xxxxxx> > --- > drivers/usb/gadget/function/u_serial.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c > index 5fedead..f58c775 100644 > --- a/drivers/usb/gadget/function/u_serial.c > +++ b/drivers/usb/gadget/function/u_serial.c > @@ -1256,7 +1256,8 @@ static void gserial_console_exit(void) > struct gscons_info *info = &gscons_info; > > unregister_console(&gserial_cons); > - kthread_stop(info->console_thread); > + if (info->console_thread != NULL) if (info->console_thread) > + kthread_stop(info->console_thread); > gs_buf_free(&info->con_buf); > } > I can reproduce the NULL pointer dereference problem after enable g_serial console, and the issue is fixed after applying your patch. So, Tested-by: Peter Chen <peter.chen@xxxxxxx> However, but there is no console enabled information, but console disabled information is existed like below, I am wondering if it is a problem. root@imx6qdlsolo:~# modprobe g_serial [ 57.305294] g_serial gadget: Gadget Serial v2.4 [ 57.310139] g_serial gadget: g_serial ready root@imx6qdlsolo:~# root@imx6qdlsolo:~# root@imx6qdlsolo:~# modprobe -r g_serial [ 113.206428] console [ttyGS-1] disabled -- Best Regards, Peter Chen -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html