[PATCH] usb: gadget: gserial: check if console kthread exists

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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_mirea@xxxxxxxxxx>
---
 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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux