Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp511097yba; Mon, 1 Apr 2019 10:45:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqwrFA5RIg9Q5AtP0r+wosZyMMwD1zrRLLXsfDunqhVbUko9cDC2BvlN+4bHmHLPQu7O91Ti X-Received: by 2002:a63:6e0e:: with SMTP id j14mr44679339pgc.203.1554140738326; Mon, 01 Apr 2019 10:45:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554140738; cv=none; d=google.com; s=arc-20160816; b=yuOkB96mGnl9mWlu1BNOkklMNDwRp7vOt7R1HYsDi+ZXGpV45ScvP+TZowTK4LC52B FM9UmDkWmKYHDLSKhMuNJV7KriJvqeE8ag3T3+h53bZ92JJDvZDcaHA76XheHS3bAYDN mhlew4qUP3sKX9WlB96izE31Z2cKNgjND4GEVMG5NwzOqrnT5KTplvUgQkvGaX+K35Of 1dRZMPCWv71Emb2lstNz+1lRAcOx45Jm7UiYXi4tQciEXrZBYsX+7QYb8EUQC3EvTXvH 5QEFjoWkYjLLm/P2XbGf54dpaKWLMH+MePYaQ4RBc++fzRu3lR7gjlPWK+Xs63Uu/eD0 mEfA== 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=e+8c2x9rtj8mqu1ZBcUQqVC2aThlO4N1J95P/ezGXiU=; b=0QgG6y1DUQhb7Xwg9IoVEf24xzc9xXIR0nQ+62UqDA+z8C1foZXjlomG9JvTxjEIw8 CSpOhyvoaJJv7AWnUSI77wTtMs0tv6tSfhDcF1vzKqk05xsf8kPr7znLX8rHBtOrVz+E wjFIFC0DrhRaO6sDa6cF449RBmQ2Oz7YY34btzFSHbW1aqHJ7i4CLsoOVLfBacIw+xkf +Wx0QG+g/zkKJjZoFNFmB/H5J7ouui7p2FucWI4KmNy3NxrBwCN/0AwyrLkUp9naICt+ v6eifBF/0Gvg9VxHCO9bLb0jTs2BjujSM0dizE7hC2+H3AVNxXLzre4rPmyo4naQTu2M XzRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=n8U7usst; 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 c14si1460583pls.106.2019.04.01.10.45.23; Mon, 01 Apr 2019 10:45:38 -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=n8U7usst; 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 S2387953AbfDARfy (ORCPT + 99 others); Mon, 1 Apr 2019 13:35:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:46880 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387585AbfDARfu (ORCPT ); Mon, 1 Apr 2019 13:35:50 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 53DEF20896; Mon, 1 Apr 2019 17:35:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554140149; bh=LYgqD5wYLO2NLFIaK4v86siK5AVdzfQ3DsLgM4LqBfo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n8U7usstpfDl0yGuf2i9pKzTlcsw3Ri0RgOIm/RAjbryf2Vd2dS4aTxcQ6xcFA9U9 bB0VCQOjz+n+NvOBONRCj3kDf7HijF3OgFQKEaSuBCST8C5xvmM/QvSpuOmzOL+c/2 PLJNzR0CnY4R6SNSN4yM7ddx8Wv26N09QbUxKh4I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rajkumar Raghupathy , Xerox Lin , Amit Pundir , Felipe Balbi , Sasha Levin Subject: [PATCH 4.4 083/131] usb: gadget: rndis: free response queue during REMOTE_NDIS_RESET_MSG Date: Mon, 1 Apr 2019 19:02:33 +0200 Message-Id: <20190401170059.049855572@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190401170051.645954551@linuxfoundation.org> References: <20190401170051.645954551@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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. ------------------ [ Upstream commit 207707d8fd48ebc977fb2b2794004a020e1ee08e ] When rndis data transfer is in progress, some Windows7 Host PC is not sending the GET_ENCAPSULATED_RESPONSE command for receiving the response for the previous SEND_ENCAPSULATED_COMMAND processed. The rndis function driver appends each response for the SEND_ENCAPSULATED_COMMAND in a queue. As the above process got corrupted, the Host sends a REMOTE_NDIS_RESET_MSG command to do a soft-reset. As the rndis response queue is not freed, the previous response is sent as a part of this REMOTE_NDIS_RESET_MSG's reset response and the Host block any more Rndis transfers. Hence free the rndis response queue as a part of this soft-reset so that the correct response for REMOTE_NDIS_RESET_MSG is sent properly during the response command. Signed-off-by: Rajkumar Raghupathy Signed-off-by: Xerox Lin [AmitP: Cherry-picked this patch and folded other relevant fixes from Android common kernel android-4.4] Signed-off-by: Amit Pundir Signed-off-by: Felipe Balbi Signed-off-by: Sasha Levin --- drivers/usb/gadget/function/rndis.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/usb/gadget/function/rndis.c b/drivers/usb/gadget/function/rndis.c index 70d3917cc003..2582db38d6a6 100644 --- a/drivers/usb/gadget/function/rndis.c +++ b/drivers/usb/gadget/function/rndis.c @@ -680,6 +680,12 @@ static int rndis_reset_response(struct rndis_params *params, { rndis_reset_cmplt_type *resp; rndis_resp_t *r; + u8 *xbuf; + u32 length; + + /* drain the response queue */ + while ((xbuf = rndis_get_next_response(params, &length))) + rndis_free_response(params, xbuf); r = rndis_add_response(params, sizeof(rndis_reset_cmplt_type)); if (!r) -- 2.19.1