Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2235859imm; Thu, 18 Oct 2018 11:09:26 -0700 (PDT) X-Google-Smtp-Source: ACcGV60qxyFApsTQG+R0j+HQX22/4FCj3tJyFvZFR8+TzYWyxF/aVVMEm/QM599T0952Jcj0bcgA X-Received: by 2002:a17:902:f203:: with SMTP id gn3mr29689966plb.93.1539886166061; Thu, 18 Oct 2018 11:09:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539886166; cv=none; d=google.com; s=arc-20160816; b=KBBMu2Epp0k6QOqZKwvxrUs247HwLNhPfNTZRQlcMj5skDj7zvckDbnAUVlZBXcue+ BT5hd4ZeQrPDmwE6nFruNuoqg3BE76oX0h+Vu3tS9ebzAvfiVIFIy0Mke8FFSywpJKw6 3SN8nuepTt553Uxcu8wjjy5QKfVsZuhI8pic/2Bou8CcaTVRQHjkMfcWJSK7Z5tAa/r2 hBNyQ5sXn07pDPmsvBPVpC9vhJnHBtCuCkEUbnyjHH9uN5bljolgbBCKN50qjk3LXCW2 UYLbwoh27lOs5MsqhKv2SLUwzuGfj8ACLnoxVQVa0GyxaIMbimngAgKPsoUHHK5cwBpr VNGg== 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=Z6kt9iHAav7zzvIOKW2UC7I4lH2KiwQpe859Isd0pbo=; b=aOKQs/eWckFeuedqwmpqmpt65jhWILYxUBwdoJBf4VlXY335JuS3sGvIaAU3qjEEuA MXDcaCM4qAGVzOd008q0OKr5NauCpnDMrjSVMndLaWWcBQTWigleT22GN+pRg45SUhZK vnqmhNxUpSeIMQNXGEEk+4LRvLYGlJMPaQL3E5z03keDR6HbmMKnnvkMGPxUtEP9MA5x QABHAsk89KoyOJGEhfSXiEok7AvX+sj3/hRhARPKtH5cQXUSwJlqVYvFxKiO01gPyY6Q DceIM78AdmjalVJrfQDofjAQrnkNQmLGS+rnJEv5JUL2pdSBqChrbYmTXhrgi9NYzwxA YJDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=quR4fDo2; 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 r134-v6si23622676pfc.202.2018.10.18.11.09.10; Thu, 18 Oct 2018 11:09:26 -0700 (PDT) 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=quR4fDo2; 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 S1730557AbeJSCIz (ORCPT + 99 others); Thu, 18 Oct 2018 22:08:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:58144 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729926AbeJSCIy (ORCPT ); Thu, 18 Oct 2018 22:08:54 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (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 31D3E2148D; Thu, 18 Oct 2018 18:06:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539886007; bh=10ZxONM01KTTzfcJEaLscfeJ4CrzGFLkir2HeyntUf0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=quR4fDo2udpA/6Sc1wHXgwwxaT56UBIHF0/g3amydHhChlGji9wW9s8rRxjFB8zAt It5KuI7m1YkmXv+XMmZkKA64tUhpBxKiuORrfP/jDeBy45/xD8hDg7rmX6t6FloFnn cY8Ug4tikKqhi6qZeQMOkdasMcK0DuSW/ly/dMVI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephen Warren , Felipe Balbi , Krzysztof Kozlowski Subject: [PATCH 4.4 44/48] usb: gadget: serial: fix oops when data rxd after close Date: Thu, 18 Oct 2018 19:55:19 +0200 Message-Id: <20181018175430.254334473@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181018175427.133690306@linuxfoundation.org> References: <20181018175427.133690306@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stephen Warren commit daa35bd95634a2a2d72d1049c93576a02711cb1a upstream. When the gadget serial device has no associated TTY, do not pass any received data into the TTY layer for processing; simply drop it instead. This prevents the TTY layer from calling back into the gadget serial driver, which will then crash in e.g. gs_write_room() due to lack of gadget serial device to TTY association (i.e. a NULL pointer dereference). Signed-off-by: Stephen Warren Signed-off-by: Felipe Balbi Signed-off-by: Krzysztof Kozlowski Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/u_serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/usb/gadget/function/u_serial.c +++ b/drivers/usb/gadget/function/u_serial.c @@ -518,7 +518,7 @@ static void gs_rx_push(unsigned long _po } /* push data to (open) tty */ - if (req->actual) { + if (req->actual && tty) { char *packet = req->buf; unsigned size = req->actual; unsigned n;