From: Bogdan Mirea Date: Sun, 30 Apr 2017 10:21:26 +0000 (+0300) Subject: usb: gadget: gserial: check if console kthread exists X-Git-Tag: MMI-PSA29.97-13-9~5558^2~30^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=844cf8a9d51f1d1e116d0bb18c353a2a94c70e79;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git usb: gadget: gserial: check if console kthread exists Check for bad pointer that may result because of kthread_create failure. This check is needed since the gserial setup callback function (gs_console_setup()) is only freeing the info->con_buf in case of kthread_create failure which will result into bad info->console_thread pointer. Without checking info->console_thread pointer validity in the gserial_console_exit() function, before calling kthread_stop(), the rmmod will generate Kernel Oops. Signed-off-by: Bogdan Mirea Signed-off-by: Felipe Balbi --- diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c index 000677c991b0..9b0805f55ad7 100644 --- a/drivers/usb/gadget/function/u_serial.c +++ b/drivers/usb/gadget/function/u_serial.c @@ -1256,7 +1256,7 @@ static void gserial_console_exit(void) struct gscons_info *info = &gscons_info; unregister_console(&gserial_cons); - if (info->console_thread != NULL) + if (!IS_ERR_OR_NULL(info->console_thread)) kthread_stop(info->console_thread); gs_buf_free(&info->con_buf); }