Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2337723ybz; Thu, 23 Apr 2020 16:17:15 -0700 (PDT) X-Google-Smtp-Source: APiQypJqvQDa3oFzXiDpweWO5sSdVvXTLGvaXPk2r/ftGotvEI+ORPhb8iO3ac86ikJBvX1F6Yf7 X-Received: by 2002:aa7:c1cf:: with SMTP id d15mr4554746edp.266.1587683835526; Thu, 23 Apr 2020 16:17:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587683835; cv=none; d=google.com; s=arc-20160816; b=KGAXbsa2ycMwKNkaFsqc1ztdxn0vZKGsRqC/Xx2r0DVL3u3YWOGCkWmvtJtjBanVig celElkVVE0I4tupeCJOkWCv603Sca8vAVGOHlFBjpUhtfBztBbMs8FBdrtPsneKXQA72 BP8BSyGufYWg8cqy+FffkE6wbcdhXHraq3RZgsa80lFa37CeehlRspcpJAVGZ+UMA69m dPyWEa/ksRHVbbf//FMkeLwf64hX1g1diAim4Tzjo6KT7Zdfft2+23LuTgJk7Bvuj5lq RjnSaWsgntoNoYrtQRvJZyMUTm3jKy0iib3PrRv6Nv8Gs+HdY9Zyd98aGH3/Frb519x/ guIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=Rb3W71yKQxwQelPML7f78c2mSAWOlT1SPLDYRtk/eAc=; b=Nqfx8Pxo8o7ewrhD/mHnnhCARFZ7HpUZDXc9lvzMdRDZc4T4TIajYx8MO0X4xTlfU3 jl7Oiy0zknKYAI2LmFqaxUsqIurn2Ut0uw7fWNKrax+UmpqZqcXEpiwBRROiA0cOE92D ztGgmkwqh9wX8LDUzWoD8ESrQaF8zTus3MjUZqkQC//gWSTYJI6bqiXyjwf6hVsM8gZ8 vM+1o1oqdVaR7pgeGk4TJvl7I+5p3URBpRhUPI0vHzSRXVt8RN8MiQ4nOIazYogrHbkO 80ukXw4Cp2bkUq50ZykBjLUpHhAG+OBzlgFaLrPP99G4qKrI+Jl3WOxDr88edNVPlc6j LpyQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d23si2157861edn.363.2020.04.23.16.16.52; Thu, 23 Apr 2020 16:17:15 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729448AbgDWXNv (ORCPT + 99 others); Thu, 23 Apr 2020 19:13:51 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:49944 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728472AbgDWXGu (ORCPT ); Thu, 23 Apr 2020 19:06:50 -0400 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1jRkvY-0004lg-K2; Fri, 24 Apr 2020 00:06:40 +0100 Received: from ben by deadeye with local (Exim 4.93) (envelope-from ) id 1jRkvX-00E6xe-RA; Fri, 24 Apr 2020 00:06:39 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "Greg Kroah-Hartman" , "Johan Hovold" Date: Fri, 24 Apr 2020 00:07:04 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 197/245] USB: serial: quatech2: handle unbound ports In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.83-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Johan Hovold commit 9715a43eea77e42678a1002623f2d9a78f5b81a1 upstream. Check for NULL port data in the modem- and line-status handlers to avoid dereferencing a NULL pointer in the unlikely case where a port device isn't bound to a driver (e.g. after an allocation failure on port probe). Note that the other (stubbed) event handlers qt2_process_xmit_empty() and qt2_process_flush() would need similar sanity checks in case they are ever implemented. Fixes: f7a33e608d9a ("USB: serial: add quatech2 usb to serial driver") Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold Signed-off-by: Ben Hutchings --- drivers/usb/serial/quatech2.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/usb/serial/quatech2.c +++ b/drivers/usb/serial/quatech2.c @@ -872,7 +872,10 @@ static void qt2_update_msr(struct usb_se u8 newMSR = (u8) *ch; unsigned long flags; + /* May be called from qt2_process_read_urb() for an unbound port. */ port_priv = usb_get_serial_port_data(port); + if (!port_priv) + return; spin_lock_irqsave(&port_priv->lock, flags); port_priv->shadowMSR = newMSR; @@ -900,7 +903,10 @@ static void qt2_update_lsr(struct usb_se unsigned long flags; u8 newLSR = (u8) *ch; + /* May be called from qt2_process_read_urb() for an unbound port. */ port_priv = usb_get_serial_port_data(port); + if (!port_priv) + return; if (newLSR & UART_LSR_BI) newLSR &= (u8) (UART_LSR_OE | UART_LSR_BI);