Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <Bogdan-Stefan_mirea@mentor.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>

authored by

Bogdan Mirea and committed by
Felipe Balbi
844cf8a9 d325a1de

+1 -1
+1 -1
drivers/usb/gadget/function/u_serial.c
··· 1256 1256 struct gscons_info *info = &gscons_info; 1257 1257 1258 1258 unregister_console(&gserial_cons); 1259 - if (info->console_thread != NULL) 1259 + if (!IS_ERR_OR_NULL(info->console_thread)) 1260 1260 kthread_stop(info->console_thread); 1261 1261 gs_buf_free(&info->con_buf); 1262 1262 }