From patchwork Fri May 18 08:37:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 10408721 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9997260230 for ; Fri, 18 May 2018 08:38:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8943C237A5 for ; Fri, 18 May 2018 08:38:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CA0423B3C; Fri, 18 May 2018 08:38:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76034237A5 for ; Fri, 18 May 2018 08:38:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753782AbeERIiH (ORCPT ); Fri, 18 May 2018 04:38:07 -0400 Received: from relmlor3.renesas.com ([210.160.252.173]:14062 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753811AbeERIh5 (ORCPT ); Fri, 18 May 2018 04:37:57 -0400 Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie2.idc.renesas.com with ESMTP; 18 May 2018 17:37:55 +0900 Received: from relmlii2.idc.renesas.com (relmlii2.idc.renesas.com [10.200.68.66]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id 4BE4C85B1C; Fri, 18 May 2018 17:37:55 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.49,413,1520866800"; d="scan'208";a="281368719" Received: from mail-ty1jpn01lp0182.outbound.protection.outlook.com (HELO JPN01-TY1-obe.outbound.protection.outlook.com) ([23.103.139.182]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 18 May 2018 17:37:55 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=D5MZjxOW686tYY05MQEuhk3iZqX1/GkloD27ToCsYRw=; b=COd+lmqbme90n6t2O8y3Q3YvRTarJhjeFldEdyBMAmNBOLv8jLgHb71hguZbU8s6BekE/SMGpyAnPE3Z7rSdRKAtRjTlYAffBopGxfCCr9+3ROyEXU8KCk4qVTbUL48o98L//yGEzVWKZ3zx5YOzzFgDC8Litdao0QxsYk8GOkc= Received: from localhost.localdomain (211.11.155.138) by TYAPR01MB2304.jpnprd01.prod.outlook.com (2603:1096:404:8::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.776.11; Fri, 18 May 2018 08:37:54 +0000 From: Yoshihiro Shimoda To: balbi@kernel.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda Subject: [PATCH/RFC] usb: gadget: function: printer: avoid wrong list handling in printer_write() Date: Fri, 18 May 2018 17:37:21 +0900 Message-Id: <1526632641-30086-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [211.11.155.138] X-ClientProxiedBy: TY1PR01CA0205.jpnprd01.prod.outlook.com (2603:1096:403::35) To TYAPR01MB2304.jpnprd01.prod.outlook.com (2603:1096:404:8::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(8559017)(48565401081)(2017052603328)(7153060)(7193020); SRVR:TYAPR01MB2304; X-Microsoft-Exchange-Diagnostics: 1; TYAPR01MB2304; 3:UbYpvdVlbTguJpbn0xc+tXqGmjaLXJMhdKSDi5Kijjt9ibe3ps64ETQ0IMfV6rFUkML9d7kdo9O7a5qNiDkSuxWwX/09s6OFXmORwCavsGhVzkC+OI7068LqXjz23wZah9kuB4UGWEQEpXwPugyf1ZDClmxdD4DA0GVSSHSAnJGpYMcLIEKZW8uxXqkOuRI47uO7ivvWKOBfJCBYlEW/oL8yQFOK8Uc3cxkzX5x9Hg9rPFv9xZOhvv4sXf9Qjr3z; 25:PmZWwsVHZBFQEdJRv6Fc/JuE19O2kM7BTOr1SdNyciIVtxG9UpaQf3JzBM3mJf7beFKaHB4bTf8zjkk0A2J+2u5l4VwpIE0Yq0HhrkHPrDXf0OS8JvA69NiDjsui1LzFvkneOHOkczGIgpGCwQ5dnqQlNCdT98UAeQUuE8914eNEdUmmv4ZM77TRHwGEmj+Qw4ZQe21B/j5iI/oryYR8WPWTlA9czDQRyerYXE7/McB7ELUUdIGr7oY3zaCTn+0rUd34SuNgDvSabRVD9QDyiLFwsR/pfGpVuuF1fCv3o3xher1mE3lBFdpUkLmLMqPdBQtVcq/hKsNN+n4tLF1vGA==; 31:bCLKDyv34x0Q/WxwFEHSDpyry8w98Oj57tUwZjHPSwSKhfwRrx0yOJ0EXX04Plq9HDmrjd1AQbREHMr9Z79+auvHzRhLaRbvWtXSLkG6WVQUCRKPpQPF35mppEF9qaSlJn9A6lwgDspkVwO/nTfeAhUYEVUjfpH/BR3fdwANx46Fwm+TExZ9DGhxIqWqeYP0+CvIosUwV3qGdl5JzKwmt+9IxgOrjseEul4e5DpoLvc= X-MS-TrafficTypeDiagnostic: TYAPR01MB2304: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=<>; X-Microsoft-Exchange-Diagnostics: 1; TYAPR01MB2304; 20:YaIGq0P+wNSDTkj4rTwQG1qrPehSWXogP4PBjElxLU5zeuZ72HgaM9KOZO+wBaFElRHQ4lAIJMHVjMFrqaICq2kIW9fjQrl72OtZLulIKxcCGr1ZiFDm97Rza0Mmo/OdeDTbWfYixnDQ1izGvAliR6DdsBozEn2jSw0ShbRmtQFYWnBt21Y5puvT9CL77hgjjmnd8iW0e7btFp/xsNpIh0NsIyGPzUWYgSHm7Mjmc3eUaNxeQ2Y+PgwSIgUBFhPdX4WPzvat9roD92j6+YwgJdEOewImNTY4t9D1MKyQdiF8yCRnE3mN4un2x7iv+Fl8QBrRdxEtBuw6occM+Y4EAG2jrbASYe+RSeH7ZTNN9Z639EGFol6Z0/P2UTe17ksVfBL+4219XC3pKt9wYyzKCLDCtRNiTyPs8j87TYZ4wPdATqFWEt5gvUmOMAQe/W2Yxbr7T1SbtU63JMIRDLoVBdsPENspzs6EbPEu1R7uVg7EF9UA6lJl83+wJ9fNX2OA; 4:pziMMKnLD0Wdew5CW4v7wcGB0E6oWVN3M9gdiJES0izLkg8UeVu4gszhgJGS7rRrvSj9wNShy2mt07ij5SJdhaLCgld8aHDtoVHwG7x20b8VV0eRblwyDat1G7s0agNIJjFXkQYy/ydKDpBhryf1PIeWFaNDmeNBFkilWQsBlbyi68R0zisRfyHEKyFvTDK7xopz5OUGGWnSfQ1m7sIE2Q9Qp5I8NbkS9eGj9XnP5TLpVxLva8shwPDjDWx0QQWMg60X0CpWI1YUHuyV0dvuLg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231254)(944501410)(52105095)(3002001)(10201501046)(93006095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061750153)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(6072148)(201708071742011)(7699016); SRVR:TYAPR01MB2304; BCL:0; PCL:0; RULEID:; SRVR:TYAPR01MB2304; X-Forefront-PRVS: 0676F530A9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6069001)(396003)(39380400002)(39860400002)(346002)(366004)(376002)(189003)(199004)(6666003)(53936002)(6512007)(97736004)(51416003)(36756003)(52116002)(6916009)(16586007)(50466002)(2361001)(2351001)(25786009)(316002)(6486002)(105586002)(48376002)(305945005)(78352004)(106356001)(498600001)(6116002)(3846002)(81166006)(8676002)(8936002)(47776003)(2616005)(107886003)(6506007)(81156014)(386003)(4326008)(956004)(59450400001)(2906002)(7736002)(42882007)(66066001)(26005)(68736007)(5660300001)(476003)(50226002)(16526019)(486006)(3720700003); DIR:OUT; SFP:1102; SCL:1; SRVR:TYAPR01MB2304; H:localhost.localdomain; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:0; A:0; Received-SPF: None (protection.outlook.com: localhost.localdomain does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; TYAPR01MB2304; 23:NscvR9MmbTmQWgJ2N5aWko5SvsV814NDzgr6MBsjV?= =?us-ascii?Q?t1u294coX33mpg6DmxqPTblYnu66MlaMvkL8YiSthz8tMM0dwSn/OGVc1Sw4?= =?us-ascii?Q?Rk1goG0dSq0kbMJZ4idU1Rxqe31IBZmRbXjD6munhOjon668xoPMZeQJ3wP+?= =?us-ascii?Q?6foX2LLfafzjStMfWSMwJ1xJh3bUv4kH9JWJm8aBZrBDAe6ehQcs4jI5Hx8U?= =?us-ascii?Q?SFggmr20ZSrI2TTRyT3QBOajUBJXn1qow2goZ6LP1aVEvT8qw51fixVsd7t7?= =?us-ascii?Q?5UDdCkUU6r7P9Dl74dz144hDYsnP/uI9tExq2Y0LlCSD5XpKGd58HOgjqu9k?= =?us-ascii?Q?7Xl1IiDeoxFtUbJd9VLA+W0yvYt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ascii?Q?rQbpsQ97FYURNBHtXU=3D?= X-Microsoft-Antispam-Message-Info: eBHGbe74+lJJ+EossDCYy9XXlpipHDyT+EjSIfVi0vjaJxurFLCXP75/mL70qewcKowo6SaDJWNkpia9DLHqxu81aUHDSRr68iyPeE556mawwrx1Zm24Md3+kb+9dtZ1N6YvJZa+3nyP+3v/IbZWcy/AdH19eT4UYOci2dLPeylJ7fGKn7nZhkHg1vLVnxc0 X-Microsoft-Exchange-Diagnostics: 1; TYAPR01MB2304; 6:0sZGSvX2pJMzCuUqWzgZsrmyoMd3o23RDeP2EwymTpe509EF9WtS1rw8fASBsJYNBw+/RL41jasV5oxGrhu5K5WYNtJI9QaxhUzl1kovWqTmWBJ9SEYtkXZSi9eOv7sUr2ELdw+5UbrB2E5Exn5+tjeUgV5af2+s6caHpk4y1ViMLCdJ5VZGWb2DoNHveK1/FxIwuf8nz3pnytnn1SaIRbTlaSTbyO+69SnVyx4QsSYkGJ1EebgfwowXUuM33DOFjkelb2YKVNsdlANW5eyBxwOVbUsoj1gEl+W0hQpIVtTUE3CkTUVUelI2Sp2TKUCE4ml+HW5bixx5ldxvtpfCfUPsJd8rm0OZKli01+zLYsqr3121QbwVPnZAOY+I40eP0+KJkugeWdBYsaeAbTXUKaUOZaLlx3ELa3YOI3c+EbU0lUFA48XX3ohVnURg1MCU7V/SoxuEmFaBtt9A4Pdiig==; 5:xrYM61ER31XGHbfbnBGFSQHTt9t15FiQQo/B8oWH416+RROBozJNORD9BEYfIM9qvY4upKWrrglUHk6YWXXGXvwzLmn36FYDBLcAJT5i4UtFR/riDgAEI3pOa5g6d9r8Pg5vIOiqexDV9vmXHA0DPVBifFVrNK8dNolxo3OQy1o=; 24:X4qA2FrFtfn2R9y1mOv6Kiaqw4RvCs8cRRR142A5ZgY/GSHIDXH4Zb59/Rlwk9e05QRin2W1EN+hG7PFIay83vbUwqGqdovDcOqXlLeAZeY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; TYAPR01MB2304; 7:oFugfAs6w1/k5Nwhw3d9mM+SsvTj1zswXs5tNXiYbyRyeNLjOO0RYDqtptc18DFpevw9WefIHLDM/Ro037wM9HUk6cTobslSCl/HgHEVPrnosdTJ+TZSaFfrW4+p/vHQvGODX/6qCSso9reeFQQmHk24pzDCCO32Qv5mkQ7hF59Bolapo7j5Sr5vgnnK39qR27YcJemRqyXgCOwG5iNEcJpifSAqlILQZ8mYcx8JD1UYX2EL/SVjjH+N6COcMXFa; 20:vIMDD4X887rDxFex5LGy6M53AMJZg8OSiBZPZErMP7d0YCR6vKb5PmUAbTLGnq9SMMX8xbc3b12+WFB6IdbGaT8EwlZ/9IqQ2CLljN+q3eGH+t5sRZQlTixBLPxmJklaQGJdbcKUiwDKaKNEUvkecktjdHkUOXBEmKAh4ZTHHyw= X-MS-Office365-Filtering-Correlation-Id: 9e892cf1-4b2c-4858-b335-08d5bc9aa62b X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2018 08:37:54.0879 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9e892cf1-4b2c-4858-b335-08d5bc9aa62b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYAPR01MB2304 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The usb_ep_queue() in printer_write() is possible to call req->complete(). In that case, since tx_complete() calls list_add(&req->list, &dev->tx_reqs), printer_write() should not call list_add(&req->list, &dev->tx_reqs_active) because the transfer has already finished. So, this patch checks the condition of req->list before adding the list in printer_write(). Signed-off-by: Yoshihiro Shimoda Acked-by: Felipe Balbi --- This issue can be caused by renesas_usbhs udc driver. I'm not sure this patch is acceptable or not. So, I marked RFC on this patch. drivers/usb/gadget/function/f_printer.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c index d359efe..01de45e 100644 --- a/drivers/usb/gadget/function/f_printer.c +++ b/drivers/usb/gadget/function/f_printer.c @@ -640,10 +640,14 @@ static void tx_complete(struct usb_ep *ep, struct usb_request *req) spin_unlock_irqrestore(&dev->lock, flags); mutex_unlock(&dev->lock_printer_io); return -EAGAIN; + } else if (list_empty(&req->list)) { + /* + * Since usb_ep_queue() is possible to call complete, + * we should check the req->list here, and then add + * it into dev->tx_reqs_active. + */ + list_add(&req->list, &dev->tx_reqs_active); } - - list_add(&req->list, &dev->tx_reqs_active); - } spin_unlock_irqrestore(&dev->lock, flags);