Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1114261pxb; Fri, 26 Feb 2021 02:58:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJyl5n841rh712v6i5euzelS1fXYlVEp/PWDJIw2pxYe9wDprz4EaE63RKSiQffGdBDVGMFU X-Received: by 2002:a17:906:1e50:: with SMTP id i16mr2641586ejj.466.1614337121633; Fri, 26 Feb 2021 02:58:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614337121; cv=none; d=google.com; s=arc-20160816; b=DtvjVcoH5Hn8nL4dsCog45YEMyTsso0Gvysn5wrjpWdyf77o2GeytSkaMzmMyfEQsq bjHEkN5GzcTwyT6kcjxvqcB9CcElB4svqQIChDF5DTyK+teN9UAHBqzWpnMVfF+1uOgF /ulXWeTfIy2oZGZDpnCSyuAkyEpPaza9Rt9Wj6ayzgDOfFOQKS+dprq+ZWTmrONzpjeF YseDvWZZXPy3YYWDSFiIlq68BBN86QeKW30y1RQWWO8q1+VyX1rEnBDO+rc4QSoz0ZMq LlE4ua5oOoYwRN9UDhV+E3oX+Ut7/yAxd9AHXtgTGmGpMPIr//DUNvnJTky8YdPSfkPa qI5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=PzEbz44BRRbpJaQVVXrf8t98pT4LN7aBcqYLN1zlU7o=; b=eqkFuYs5hWUI25rZQiPt6j67Utyc3iBco8JCr+5H9H57MLe1feKdWDBsWwFLBAlGrt WHURXOJrklQqdYVFHJv2XJfNElQZDfvsKkWAs8JDVnEj45dcUbI7J5HhIFTucOfwMKgk cSQ8Z9hjaO3+nBOmO3Gm8ATgs37PjcRV2jGIP6ePsZI8G9KUJJkc2iPu6PdNtlqPsb+Q 0Y/Oozh7OZX0w75cIacQ6trZpUYASVAU5mwPmWckRFz0a7x0NnHU4gf2UQIWLnTefVF0 As91gonuYxNKhwV9NaeE3jWmZ/dvX5rQ+AiJPcuGbq4lydX30KGNvrQ8o92xjF3256Uk Ra6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IV33vp+b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z1si5765717ejm.289.2021.02.26.02.58.18; Fri, 26 Feb 2021 02:58:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IV33vp+b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230362AbhBZKze (ORCPT + 99 others); Fri, 26 Feb 2021 05:55:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:58186 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230083AbhBZKzc (ORCPT ); Fri, 26 Feb 2021 05:55:32 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 421E164EE1; Fri, 26 Feb 2021 10:54:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614336891; bh=edOHBPkEfxZwmBzRX/ETwqCCjnmKyxVyCmVbup1TnxI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=IV33vp+bm0TaEniNyLKnEhZNNyMe5o6i0vDlknB2i7pKOibVQL/cbZbCBFHcyjtVo tQF7NCMzUDK4L8fulLQ3GX094g3mrbsGl8AP32nLPXpEnebmUXSW2JYEiXw8dSH1Sd eV9KCdza8kopNvajD3TTsMQru5v/fCglwZuWTLOEU5b1lbZgHUhkf9tEHMoqbWGQJy n8diK9/PcJoLLiWEs5QndEKqE36ya/9JyzZU7L6pevpdxlCeAppV6nDjzt0RWUuoMA BjvnSaDJVoJJMZAlMaIEymDES9r+spxtuNRocOkmvsbt/BVDN8DQbX2YZ68LSdflXM 5yagWUk1uAF3Q== Date: Fri, 26 Feb 2021 11:54:47 +0100 From: Mauro Carvalho Chehab To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: Re: [PATCH] USB: serial: xr: fix NULL-deref on disconnect Message-ID: <20210226115447.6ace5490@coco.lan> In-Reply-To: <20210226100826.18987-1-johan@kernel.org> References: <20210226100826.18987-1-johan@kernel.org> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Fri, 26 Feb 2021 11:08:26 +0100 Johan Hovold escreveu: > Claiming the sibling control interface is a bit more involved and > specifically requires adding support to USB-serial core for managing > either interface being unbound first, something which could otherwise > lead to a NULL-pointer dereference. > > Similarly, additional infrastructure is also needed to handle suspend > properly. > > Since the driver currently isn't actually using the control interface, > we can defer this for now by simply not claiming the control interface. > > Fixes: c2d405aa86b4 ("USB: serial: add MaxLinear/Exar USB to Serial driver") > Reported-by: Mauro Carvalho Chehab > Cc: Manivannan Sadhasivam > Signed-off-by: Johan Hovold That solved the issue with XR21V1410: [ 8176.265862] usbcore: registered new interface driver xr_serial [ 8176.265885] usbserial: USB Serial support registered for xr_serial [ 8176.265921] xr_serial 2-1:1.1: xr_serial converter detected [ 8176.266041] usb 2-1: xr_serial converter now attached to ttyUSB0 [ 8176.268023] printk: console [ttyUSB0] enabled [ 8186.512841] usb 2-1: USB disconnect, device number 5 [ 8186.513131] printk: console [ttyUSB0] disabled [ 8186.513340] xr_serial ttyUSB0: xr_serial converter now disconnected from ttyUSB0 [ 8186.513376] xr_serial 2-1:1.1: device disconnected Tested-by: Mauro Carvalho Chehab Regards, Mauro > --- > drivers/usb/serial/xr_serial.c | 25 ------------------------- > 1 file changed, 25 deletions(-) > > diff --git a/drivers/usb/serial/xr_serial.c b/drivers/usb/serial/xr_serial.c > index 483d07dee19d..0ca04906da4b 100644 > --- a/drivers/usb/serial/xr_serial.c > +++ b/drivers/usb/serial/xr_serial.c > @@ -545,37 +545,13 @@ static void xr_close(struct usb_serial_port *port) > > static int xr_probe(struct usb_serial *serial, const struct usb_device_id *id) > { > - struct usb_driver *driver = serial->type->usb_driver; > - struct usb_interface *control_interface; > - int ret; > - > /* Don't bind to control interface */ > if (serial->interface->cur_altsetting->desc.bInterfaceNumber == 0) > return -ENODEV; > > - /* But claim the control interface during data interface probe */ > - control_interface = usb_ifnum_to_if(serial->dev, 0); > - if (!control_interface) > - return -ENODEV; > - > - ret = usb_driver_claim_interface(driver, control_interface, NULL); > - if (ret) { > - dev_err(&serial->interface->dev, "Failed to claim control interface\n"); > - return ret; > - } > - > return 0; > } > > -static void xr_disconnect(struct usb_serial *serial) > -{ > - struct usb_driver *driver = serial->type->usb_driver; > - struct usb_interface *control_interface; > - > - control_interface = usb_ifnum_to_if(serial->dev, 0); > - usb_driver_release_interface(driver, control_interface); > -} > - > static const struct usb_device_id id_table[] = { > { USB_DEVICE(0x04e2, 0x1410) }, /* XR21V141X */ > { } > @@ -590,7 +566,6 @@ 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, Thanks, Mauro