In the current implementation we get a Kernel Oops when calling rmmod
for g_serial driver. This happens because the function that creates the
kthread (gs_console_setup) which should be called at driver probing is
never called for ttyGS* resulting in a null info->console_thread
pointer.

Noticed this behaviour on Renesas Rcar-H3 Salvator-X (R8A7795).

Signed-off-by: Bogdan Mirea <bogdan-stefan_mi...@mentor.com>
---
 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 e0cd1e4..7283ff5 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 && !IS_ERR(info->console_thread))
+               kthread_stop(info->console_thread);
        gs_buf_free(&info->con_buf);
 }
 
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to