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

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

 



Hello,

On Sunday, April 30, 2017 12:30 AM Sergei Shtylyov wrote:

> Hello!
>
> On 4/29/2017 4:26 PM, Bogdan Mirea wrote:
>
> > 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@xxxxxxxxxx>
> > ---
> >  drivers/usb/gadget/function/u_serial.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/usb/gadget/function/u_serial.c 
> > b/drivers/usb/gadget/function/u_serial.c
> > index 4be1e7e..0f53b0b 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 (info->console_thread != NULL && !IS_ERR(info->console_thread))
> 
>     There is IS_ERR_OR_NULL() for that, no?
   Yes, IS_ERR_OR_NULL() will fit just fine, I'll update the patch.
Thank you!
> 
> >  		kthread_stop(info->console_thread);
> >  	gs_buf_free(&info->con_buf);
> >  }

Best Regards,
Bogdan
��.n��������+%������w��{.n�����{���)��jg��������ݢj����G�������j:+v���w�m������w�������h�����٥




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

  Powered by Linux