Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3712548ybv; Mon, 10 Feb 2020 05:09:43 -0800 (PST) X-Google-Smtp-Source: APXvYqywSle7Q9GcWD4w3Yg0TpR0lIc88QBJNpDq2TRUzHAAOyMQk5FrsJDLZYyw8niQGgw6FNkk X-Received: by 2002:a05:6830:10c4:: with SMTP id z4mr1035199oto.120.1581340183089; Mon, 10 Feb 2020 05:09:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581340183; cv=none; d=google.com; s=arc-20160816; b=g3Cztr263/OsauchDSY4GckGVwE/CZxkzvOHu6YqVKgz8NIWrtcQhNVkWWW9k4H+9l K7EAYt/LeqWVtool0xCYIXaMGzZ3oXg3V2aDbFwVcnaVa2mXjrqJ09PTJ6EYNVee5SCv 3UludkJmoQ8fuMXUbU6dzm+OZxLFH1hsgpwctGEnJNXhcYQqi0FWL+/B8PwTueCBW8dt 8koBZBmFr9Yw7fONaYAqBfPckw1hYw+ceergfcO/zglLfs2Zlz1saR1yg/a1SXikQAnp e/C4SuUGaE3yyTul08TnHwcuaWlC66dUHili6dF2mT8UUvxysVN8IF9eSlDYj3hmUWH3 GxUw== 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=ydd+WjlhLq1n4DlaOFE3JruoIQE89tY3hP58qkjj3G4=; b=B+UaWTRwBgXwqVd41JQE9eTOawhxZAeGfHIenYSzCe/Bo7pLvRPq4gmScSJQ5ZigYz sQalCW/NpgRnWrfCfYvZ9vVlIZZHu5kO7GbpYSb59QX+yx4q8WmGxiEGQM/XEW6CILol Pk49ShXX4ZzL/REe2ZU53MbgMsYbNlqWRrP4QAheVaDhIyPMxwj9IgnvSdHuRQaA5P3D rIqsTynK9xLFYrlmByUd8LTLtHmQ42upYbQSg/IKKsV/iRFe29hC43BzSnjMNz3pQymM cVfCyH/9R//BmQ47xmVYGAC8hN5vetPRX4qG1SarlwSU0irz+cUPx2N3NrrW1orscRl+ f2Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UVy8k0+W; 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 m5si120766oie.240.2020.02.10.05.09.31; Mon, 10 Feb 2020 05:09:43 -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=UVy8k0+W; 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 S1729504AbgBJNI1 (ORCPT + 99 others); Mon, 10 Feb 2020 08:08:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:37632 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729441AbgBJMje (ORCPT ); Mon, 10 Feb 2020 07:39:34 -0500 Received: from localhost (unknown [209.37.97.194]) (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 15C3F20842; Mon, 10 Feb 2020 12:39:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338374; bh=ZgdRohyeoqyTe+zFijsGSWH8xU5n9mO1FJu1F/BIhj0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UVy8k0+WwvNCWuR2J4ZP7GT/fhXneKnH8yguFhJwjxqlhh/Y6o2CUnggAnXo2BaLW BKMEwBDPHrO8cPSbr7zoLQMSl4eTMPFvBSvo/QWdYJ5ulnhr/dVpgkf1ec0gAdCvo7 l5In4osbZE1CQ6LjKUA/jh2Ff5WehQgfSFAdA7M0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jun Li , Peter Chen , Felipe Balbi Subject: [PATCH 5.5 047/367] usb: gadget: f_fs: set req->num_sgs as 0 for non-sg transfer Date: Mon, 10 Feb 2020 04:29:20 -0800 Message-Id: <20200210122428.383827294@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122423.695146547@linuxfoundation.org> References: <20200210122423.695146547@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: Peter Chen commit d2450c6937018d40d4111fe830fa48d4ddceb8d0 upstream. The UDC core uses req->num_sgs to judge if scatter buffer list is used. Eg: usb_gadget_map_request_by_dev. For f_fs sync io mode, the request is re-used for each request, so if the 1st request->length > PAGE_SIZE, and the 2nd request->length is <= PAGE_SIZE, the f_fs uses the 1st req->num_sgs for the 2nd request, it causes the UDC core get the wrong req->num_sgs value (The 2nd request doesn't use sg). For f_fs async io mode, it is not harm to initialize req->num_sgs as 0 either, in case, the UDC driver doesn't zeroed request structure. Cc: Jun Li Cc: stable Fixes: 772a7a724f69 ("usb: gadget: f_fs: Allow scatter-gather buffers") Signed-off-by: Peter Chen Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/f_fs.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -1062,6 +1062,7 @@ static ssize_t ffs_epfile_io(struct file req->num_sgs = io_data->sgt.nents; } else { req->buf = data; + req->num_sgs = 0; } req->length = data_len; @@ -1105,6 +1106,7 @@ static ssize_t ffs_epfile_io(struct file req->num_sgs = io_data->sgt.nents; } else { req->buf = data; + req->num_sgs = 0; } req->length = data_len;