Subject: Re: [PATCH] net: hso: fix module unloading

From: Johan Hovold <[email-masked]>
Date: Tue, 25 Apr 2017 12:04:59 +0200

On Mon, Apr 24, 2017 at 09:18:39PM +0200, Andreas Kemnade wrote:
> keep tty driver until usb driver is unregistered
> rmmod hso
> produces traces like this without that:

Yeah, a blatant use-after-free.

> Signed-off-by: Andreas Kemnade <[email-masked]>

Reviewed-by: Johan Hovold <[email-masked]>

> ---
>  drivers/net/usb/hso.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
> index 2e66340..b75e23f 100644
> --- a/drivers/net/usb/hso.c
> +++ b/drivers/net/usb/hso.c
> @@ -3293,9 +3293,9 @@ static void __exit hso_exit(void)
>  	pr_info("unloaded\n");
>  
>  	tty_unregister_driver(tty_drv);
> -	put_tty_driver(tty_drv);
>  	/* deregister the usb driver */
>  	usb_deregister(&hso_driver);
> +	put_tty_driver(tty_drv);
>  }
>  
>  /* Module definitions */

Thanks,
Johan