From patchwork Thu Nov 24 17:04:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Keeping X-Patchwork-Id: 25643 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3512624wrr; Thu, 24 Nov 2022 09:07:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf7QTp93htCer5Oc8hkLmAKPT002CON1FmEB6qZ63msm4Ov/iNOluydWpioxwvChpQD0srjb X-Received: by 2002:a17:906:a889:b0:7ad:bd02:f491 with SMTP id ha9-20020a170906a88900b007adbd02f491mr29650519ejb.703.1669309631266; Thu, 24 Nov 2022 09:07:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669309631; cv=none; d=google.com; s=arc-20160816; b=oG0Cte8AHvqHy2ON2H++x4JSRuuCzPWSkcZxOiu6kWFXsdmiheZfP1d/LLWWY0Qy6G Kwfe4lbunKSKlfn++vJVnCPBSNub6uqPWNZCdKRbfVMDhMYPjDWplClvLLcmL2gqkKbE +wvkkbncSgUwX79GXzDQtxnOp8quRcHWnaY+P8jCmAR2WpP6Iow0ivHZzAq5jojgHWlw 5B0DMjzQvNoXPu1GGe4LoKpOWFAXjG3WSeUd7TStkrG+vxXzZ/vS+IaHmnquQAGAgCU6 qYwNjW8D4Vt7BZVN9ObeI24cievXmr2r1nJn/Qm/ko5QC4koJGDwGU7Y1Vi11C5rV8P1 GjFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=/K9WVPVMPasDt2GUsLve9o5Zh3vIW7gvBXUy8+n3CAE=; b=dPP2LI7HcKiQz978J3N9Yq6uSv+SebQ3XplXqurEW/L/cD37vKoCKOZsUXSY59+zre gcqI7w3Kp/PIoVJRiqZ+GEDploBUV+6to8ZWX7GBZ25XRb1S0W6ePAAgcQeDCWfUVom3 dDF1TIEtEIQSuwcqqdKHLOImF7EOTSh+2x0MSSegNzdugOaBgTd1sqBAJJjKSR35Vf2u YjlrZmaUMFhfqlE/qnLGLHnfH1ozo52eV12B0Gu6myt0QvddkO8U+Y0ww8N7UTbzi2AP szM0vnc4r0Gemwr41VIi1XkX0isCmm2Kl81V+s57JstQ2i/Foeywaw+DOU+TvFzjQJny JwmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@metanate.com header.s=stronger header.b=cxgTekk7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=metanate.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fj4-20020a1709069c8400b007ae0e8f59a6si1284467ejc.821.2022.11.24.09.06.44; Thu, 24 Nov 2022 09:07:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@metanate.com header.s=stronger header.b=cxgTekk7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=metanate.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229576AbiKXREs (ORCPT + 99 others); Thu, 24 Nov 2022 12:04:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229379AbiKXREp (ORCPT ); Thu, 24 Nov 2022 12:04:45 -0500 Received: from metanate.com (unknown [IPv6:2001:8b0:1628:5005::111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 979972B1BB; Thu, 24 Nov 2022 09:04:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metanate.com; s=stronger; h=Content-Transfer-Encoding:Message-Id:Date: Subject:Cc:To:From:Content-Type:Reply-To:Content-ID:Content-Description: In-Reply-To:References; bh=/K9WVPVMPasDt2GUsLve9o5Zh3vIW7gvBXUy8+n3CAE=; b=cx gTekk7r1nQ3wMUXIJPF/+3zwT4r9xiA/sMJaffqqLN38HakS33On1EJAMj0ViA4ZfZxBiZ4D81ZLX Fi+IbRaglEGul1CpltlNRMXCgN2dvc5g7Ao83QmK5JV1V5dREDx3ffNoKvE6wL9xOlYA5K4pRPiHp 1pmxx7v+TOR7R248voHq3YUS4GXGOK1cvDYU83zSaSczRRkfJkIJoxGquMW/94uH6I3xoTh3bUtDh G3lCDoEmQ5UHulsP9VF+y9SMSJLBDSFwSsp060dAAdF9OxonSyhvcE8xzwaYs+1ewcmYygwkjp8MX RWtxjA5wltrHLfPd+wUiBRzKNhOdk+Dg==; Received: from [81.174.171.191] (helo=donbot.metanate.com) by email.metanate.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1oyFeO-0000NB-7e; Thu, 24 Nov 2022 17:04:36 +0000 From: John Keeping To: linux-usb@vger.kernel.org Cc: John Keeping , Linyu Yuan , Greg Kroah-Hartman , Shuah Khan , Wolfram Sang , Dan Carpenter , linux-kernel@vger.kernel.org Subject: [PATCH] usb: gadget: f_fs: use io_data->status consistently Date: Thu, 24 Nov 2022 17:04:28 +0000 Message-Id: <20221124170430.3998755-1-john@metanate.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Authenticated: YES X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RDNS_NONE,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750398015682267472?= X-GMAIL-MSGID: =?utf-8?q?1750398015682267472?= Commit fb1f16d74e26 ("usb: gadget: f_fs: change ep->status safe in ffs_epfile_io()") added a new ffs_io_data::status field to fix lifetime issues in synchronous requests. While there are no similar lifetime issues for asynchronous requests (the separate ep member in ffs_io_data avoids them) using the status field means the USB request can be freed earlier and that there is more consistency between the synchronous and asynchronous I/O paths. Cc: Linyu Yuan Signed-off-by: John Keeping Reviewed-by: Linyu Yuan --- drivers/usb/gadget/function/f_fs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 73dc10a77cde..1221f0d1b1a9 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -825,8 +825,7 @@ static void ffs_user_copy_worker(struct work_struct *work) { struct ffs_io_data *io_data = container_of(work, struct ffs_io_data, work); - int ret = io_data->req->status ? io_data->req->status : - io_data->req->actual; + int ret = io_data->status; bool kiocb_has_eventfd = io_data->kiocb->ki_flags & IOCB_EVENTFD; if (io_data->read && ret > 0) { @@ -840,8 +839,6 @@ static void ffs_user_copy_worker(struct work_struct *work) if (io_data->ffs->ffs_eventfd && !kiocb_has_eventfd) eventfd_signal(io_data->ffs->ffs_eventfd, 1); - usb_ep_free_request(io_data->ep, io_data->req); - if (io_data->read) kfree(io_data->to_free); ffs_free_buffer(io_data); @@ -856,6 +853,9 @@ static void ffs_epfile_async_io_complete(struct usb_ep *_ep, ENTER(); + io_data->status = req->status ? req->status : req->actual; + usb_ep_free_request(_ep, req); + INIT_WORK(&io_data->work, ffs_user_copy_worker); queue_work(ffs->io_completion_wq, &io_data->work); }