> -----Original Message-----
> From: Mauro Carvalho Chehab <mche...@kernel.org> On Behalf Of Mauro
> Carvalho Chehab
> 
>  static int xr_probe(struct usb_serial *serial, const struct usb_device_id 
> *id)
>  {
> +     struct xr_port_private *port_priv;
> +
>       /* Don't bind to control interface */
>       if (serial->interface->cur_altsetting->desc.bInterfaceNumber == 0)
>               return -ENODEV;
> 
> +     port_priv = kzalloc(sizeof(*port_priv), GFP_KERNEL);
> +     if (!port_priv)
> +             return -ENOMEM;
> +
> +     port_priv->model = id->driver_info;
> +
> +     usb_set_serial_data(serial, port_priv);
> +
>       return 0;
>  }
> 
> +static void xr_disconnect(struct usb_serial *serial)
> +{
> +     struct xr_port_private *port_priv = usb_get_serial_data(serial);
> +
> +     kfree(port_priv);
> +     usb_set_serial_data(serial, 0);

Probably a nitpick, but shouldn't usb_set_serral_data() be called before 
kfree()?

> +}
> +
>  static const struct usb_device_id id_table[] = {
> -     { USB_DEVICE(0x04e2, 0x1410) }, /* XR21V141X */
> +     { USB_DEVICE(0x04e2, 0x1410), .driver_info = XR21V141X},
>       { }
>  };
>  MODULE_DEVICE_TABLE(usb, id_table);
> @@ -566,6 +640,7 @@ static struct usb_serial_driver xr_device = {
>       .id_table               = id_table,
>       .num_ports              = 1,
>       .probe                  = xr_probe,
> +     .disconnect             = xr_disconnect,
>       .open                   = xr_open,
>       .close                  = xr_close,
>       .break_ctl              = xr_break_ctl,
> --
> 2.29.2

Reply via email to