From patchwork Thu Nov 12 04:37:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 7599351 Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 90EC7BF90C for ; Thu, 12 Nov 2015 04:38:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AF994207A0 for ; Thu, 12 Nov 2015 04:37:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BA291207CB for ; Thu, 12 Nov 2015 04:37:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753410AbbKLEhw (ORCPT ); Wed, 11 Nov 2015 23:37:52 -0500 Received: from relmlor2.renesas.com ([210.160.252.172]:36386 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753354AbbKLEhu (ORCPT ); Wed, 11 Nov 2015 23:37:50 -0500 Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie1.idc.renesas.com with ESMTP; 12 Nov 2015 13:37:47 +0900 Received: from relmlac2.idc.renesas.com (relmlac2.idc.renesas.com [10.200.69.22]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id DDE5840728; Thu, 12 Nov 2015 13:37:47 +0900 (JST) Received: by relmlac2.idc.renesas.com (Postfix, from userid 0) id C9CE22806D; Thu, 12 Nov 2015 13:37:47 +0900 (JST) Received: from relmlac2.idc.renesas.com (localhost [127.0.0.1]) by relmlac2.idc.renesas.com (Postfix) with ESMTP id 9D6D32806E; Thu, 12 Nov 2015 13:37:47 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac2.idc.renesas.com with ESMTP id PBS08422; Thu, 12 Nov 2015 13:37:47 +0900 X-IronPort-AV: E=Sophos;i="5.20,279,1444662000"; d="scan'";a="199575419" Received: from mail-pu1apc01lp0022.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.22]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 12 Nov 2015 13:37:46 +0900 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=<>; Received: from localhost (211.11.155.144) by SIXPR06MB0922.apcprd06.prod.outlook.com (10.162.173.157) with Microsoft SMTP Server (TLS) id 15.1.318.15; Thu, 12 Nov 2015 04:37:45 +0000 From: Yoshihiro Shimoda To: , CC: , , Yoshihiro Shimoda Subject: [PATCH] dmaengine: usb-dmac: fix endless loop in usb_dmac_chan_terminate_all() Date: Thu, 12 Nov 2015 13:37:40 +0900 Message-ID: <1447303060-7880-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.4.msysgit.1 MIME-Version: 1.0 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: HK2PR02CA0009.apcprd02.prod.outlook.com (25.163.104.147) To SIXPR06MB0922.apcprd06.prod.outlook.com (25.162.173.157) X-Microsoft-Exchange-Diagnostics: 1; SIXPR06MB0922; 2:x5/jc/PWgTFG8iZ6HjqM4FRgHi8Edm8j2I42h7H1tjKBtLg2teQa8Gbo7sTn34QiAkvDgS2OekBuDumkOoKprYyV7Au4Yr3nUp5Jp4wBT3wbwY+ntdOsEdMrMp1TvzKltxAxi/QNne/WG2mlCNRxcUWO3Rs3yzmta+xjXryaHpQ=; 3:iOv6uYhlA+/eUomzeFG3bSq3+wQyLjpZdVYaolH1bRfIAu2Wqtd6tw4j2x98QAlbdyNoleGgQLhLF/90/q3IToXV2HfPlRmqqr3hzXFUF3daK083omCB7jgzJOWyQk552hjS6VPu/xsDLsoeuAIsIw==; 25:b71beusPUni7UVMk5bSEo9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j8mTtjjRhEVC91IPc1+3D1UrW/UfU5EFn18IUPgaYD5hfQPZEUJrtvhJLVqJq26JyVYd27hMfw69MHXn2wZUAUrDlswPHObdfgeADTcPk2x9zOKBaeLO925FFa55T6nKs2a5z6xld1lt63mk9RZ05tzTpDQblaxuFybfG0vyH7LLb1 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(85106069007906); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(520078)(3002001)(10201501046); SRVR:SIXPR06MB0922; BCL:0; PCL:0; RULEID:; SRVR:SIXPR06MB0922; X-Forefront-PRVS: 07584EDBCD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(6069001)(199003)(189002)(106356001)(66066001)(229853001)(42186005)(48376002)(50986999)(40100003)(76506005)(87976001)(77096005)(50226001)(5003940100001)(122386002)(5007970100001)(47776003)(42382002)(78352002)(105586002)(101416001)(189998001)(50466002)(5001770100001)(4001430100002)(81156007)(33646002)(19580395003)(107886002)(19580405001)(5001960100002)(97736004)(36756003)(5001920100001)(92566002)(5004730100002)(5008740100001); DIR:OUT; SFP:1102; SCL:1; SRVR:SIXPR06MB0922; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; A:0; MX:0; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SIXPR06MB0922; 23:WtIC6n5nkya+UMiV6oRTBbnH6KlufF0TIOGEzQ7ZX?= =?us-ascii?Q?7JYuhuhn1sv1YVCNVJBx5zQII8RaHwZHrGb+6bm7DYS35vvIKcMelOgnXmoR?= =?us-ascii?Q?oByQXCo8XyPFH6SpMx7bXDBEXOR29m1jEVlgnU+8zDNMZj1m7lKuX2Nz7T0k?= =?us-ascii?Q?YT0kaX2ohxh4ioXtDuQMsW4kyPaUJgL19W6qEDPUYzS6XGidsGIvMuTt1tSg?= =?us-ascii?Q?hKCSWzYJAR0KAyuMy9NaCRnEZfnW66ALL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ics: 1; SIXPR06MB0922; 5:yISNt5kxi0wjnLlrcOeMLrf6sc4kcabrBzLj8Jzw0iXnlQwySHcR41G5RDeBX5vnqUiybWaz8g8/doC9gCSHR0m609yBQ0MFqCc6C9na/B8EgqS3w+TURSEKX8UmHj1rjGCD8AS1K8EOSuzHZ6pUlA==; 24:Jqt3CFBz9qeNUDHx3HKckV4u30igtl0tDqPyGqaCBmyGpUv1I5YlIquINxfXrlUI5BHr+4Y4680eBLyBLZXh1PYM6a4vmLzb3IHgCfBgNe0=; 20:SVF/PfK85RvDg6A2gUUHLykslbBQptGisYcod/KwmkzOuMLTeajLXr3l4bAFa5/Vk5FzJC8lS3RMQeiTgoAe+xn+07g2h9sPpJC5JrQhnGIYL/q82RnPnJBJ+opYwrtmc1GdlNPlvLA10nsxxcv6Qik1PE7kuDfiU/qfs1jvl5k= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2015 04:37:45.2534 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SIXPR06MB0922 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-3.9 required=5.0 tests=AXB_X_OUTLOOKPROT_ENVSDR, BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch fixes an issue that list_for_each_entry() in usb_dmac_chan_terminate_all() is possible to cause endless loop because this will move own desc to the desc_freed. So, this driver should use list_for_each_entry_safe() instead of list_for_each_entry(). Signed-off-by: Yoshihiro Shimoda --- drivers/dma/sh/usb-dmac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/dma/sh/usb-dmac.c b/drivers/dma/sh/usb-dmac.c index ebd8a5f..16fb330 100644 --- a/drivers/dma/sh/usb-dmac.c +++ b/drivers/dma/sh/usb-dmac.c @@ -448,7 +448,7 @@ usb_dmac_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, static int usb_dmac_chan_terminate_all(struct dma_chan *chan) { struct usb_dmac_chan *uchan = to_usb_dmac_chan(chan); - struct usb_dmac_desc *desc; + struct usb_dmac_desc *desc, *_desc; unsigned long flags; LIST_HEAD(head); LIST_HEAD(list); @@ -459,7 +459,7 @@ static int usb_dmac_chan_terminate_all(struct dma_chan *chan) if (uchan->desc) uchan->desc = NULL; list_splice_init(&uchan->desc_got, &list); - list_for_each_entry(desc, &list, node) + list_for_each_entry_safe(desc, _desc, &list, node) list_move_tail(&desc->node, &uchan->desc_freed); spin_unlock_irqrestore(&uchan->vc.lock, flags); vchan_dma_desc_free_list(&uchan->vc, &head);