Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4831874ybl; Wed, 22 Jan 2020 05:33:38 -0800 (PST) X-Google-Smtp-Source: APXvYqwpujm39Vm6M39uRb17T0M0G0GbR+uxxWAl+yHAkJOSyiwjLmlEK5zAc6p3PSWsTOYcakNM X-Received: by 2002:a05:6830:1607:: with SMTP id g7mr7347092otr.320.1579700018003; Wed, 22 Jan 2020 05:33:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579700017; cv=none; d=google.com; s=arc-20160816; b=YZqpke4tkXdwcspMAcnnuCIpovr+YMAx+BrfTznRa7mjiogJdfkkrv/Op1+2+xEV9E QHYhqSxQvK0Pr/bLKwn4Rra/kHI05wdJ7jt36aK5ucRoAxG9ba5nedpRR3wBOQ2i0Rfb xO9YPPycTtASMmv0/ebBYXCiVWLcWZIiTAKhE50xD12hbZ25POoy1Jg1ZWKJ8JQpZy5y l6MAZKmMjkwuasa08QYizUDP/ifBq5Y/0xKwrJzD5jI/4hQySpMaK2mmMXks7q+qPBhU YBaTyZNDE6l36ZW97k3Grmq2ZqJ0to5TnnSZDQzZMNjjFWulRzUe1mVVEvOJyzNopqRO M5RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+z+sw3SLNwvuN4gPehUcXNA7j8LgFyT2iYwK2fR4xSQ=; b=UYpUg0AshFD8QuYXVSBLfMRXaVhLjg+Q4jlHLqOdlxlMCVJU9omwut/5vCvLBjP/hl lJ0Ib21UNn0bj6/paWK8aAhsJAgd0uLD7yV+gLR4OOworP2LF9BWzVSPnJ2+sd0BA3NK +FJPQBwUfd4KydF6yCkrIri9t81XwrKbgRcLXMFolQG8pbZ9R29TIBEQ4d5+2xQcqCIp rhX0fhi+x0gEjfo90Mhufuf7n5ZKal/CsZ3hfNvFp5RmVP5nyWfoU07GYqCrAUrDxKe4 xP7hsNyTOcASitUdYzWfQZXtKTroHlri73dO748aAjYtxoXeTXC90KribQkhsTTlcytG I3hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PHtCm11g; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h11si23201321otr.197.2020.01.22.05.33.23; Wed, 22 Jan 2020 05:33:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PHtCm11g; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725946AbgAVNSu (ORCPT + 99 others); Wed, 22 Jan 2020 08:18:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:34528 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729424AbgAVNSq (ORCPT ); Wed, 22 Jan 2020 08:18:46 -0500 Received: from localhost (unknown [84.241.205.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9B32520678; Wed, 22 Jan 2020 13:18:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579699126; bh=i5LGxRby5DJsvcfekIq4ozkKD+9xhtVq6Jkdof7oRi0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PHtCm11guWWda6zZN/p5IdtdoaYWPCpsoKqImdSgC5ZTTXa45PsclgZFQ8L8qWUXt srS4tOLA3HTIzttH2AGPc62M8BlsuWSjB/zRrualXusTa2ATL9oxEkcMJpgAyrgAFm Q+MRtSL33VaN+n/XrFFQoHFThuhFrItykBbV1Rk8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold Subject: [PATCH 5.4 049/222] USB: serial: io_edgeport: handle unbound ports on URB completion Date: Wed, 22 Jan 2020 10:27:15 +0100 Message-Id: <20200122092837.111988670@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092833.339495161@linuxfoundation.org> References: <20200122092833.339495161@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johan Hovold commit e37d1aeda737a20b1846a91a3da3f8b0f00cf690 upstream. Check for NULL port data in the shared interrupt and bulk completion callbacks to avoid dereferencing a NULL pointer in case a device sends data for a port device which isn't bound to a driver (e.g. due to a malicious device having unexpected endpoints or after an allocation failure on port probe). Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/io_edgeport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -716,7 +716,7 @@ static void edge_interrupt_callback(stru if (txCredits) { port = edge_serial->serial->port[portNumber]; edge_port = usb_get_serial_port_data(port); - if (edge_port->open) { + if (edge_port && edge_port->open) { spin_lock_irqsave(&edge_port->ep_lock, flags); edge_port->txCredits += txCredits; @@ -1825,7 +1825,7 @@ static void process_rcvd_data(struct edg port = edge_serial->serial->port[ edge_serial->rxPort]; edge_port = usb_get_serial_port_data(port); - if (edge_port->open) { + if (edge_port && edge_port->open) { dev_dbg(dev, "%s - Sending %d bytes to TTY for port %d\n", __func__, rxLen, edge_serial->rxPort);