From patchwork Tue Dec 12 08:27:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia-Ju Bai X-Patchwork-Id: 10106483 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 D1DF8602C2 for ; Tue, 12 Dec 2017 08:27:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C266C29B02 for ; Tue, 12 Dec 2017 08:27:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B752929AFB; Tue, 12 Dec 2017 08:27:04 +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=-3.7 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SBL_CSS autolearn=unavailable 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 6B32429AFB for ; Tue, 12 Dec 2017 08:27:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751542AbdLLI0u (ORCPT ); Tue, 12 Dec 2017 03:26:50 -0500 Received: from m12-13.163.com ([220.181.12.13]:41486 "EHLO m12-13.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750955AbdLLI0u (ORCPT ); Tue, 12 Dec 2017 03:26:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=koMRAxJ3OtrMJCaWbL jBMjtpryMq4VP5g9qYMZ6dRdA=; b=JwYqCU2I50yhPD0pjj4d3UIHESPffkj6Xr RMFdHWbBDQF9Zztdxz8r53UyjtOgPsHPqXAyi/h/l/ZGwahHe2xgBJ3DnvqabrxP c0XJ4EJg/RR61ifuCGTBSRU7mJu/Ulh/SXIkw1Un8te68H6v21zZyhY3Zu8J/9/d GCUj0uzXg= Received: from bai-oslab.tsinghua.edu.cn (unknown [166.111.70.15]) by smtp9 (Coremail) with SMTP id DcCowABnfYJ+ki9aqUIlAg--.2212S2; Tue, 12 Dec 2017 16:25:39 +0800 (CST) From: Jia-Ju Bai To: linuxdrivers@attotech.com, jejb@linux.vnet.ibm.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] esas2r: Fix a possible sleep-in-atomic bug in esas2r_wait_request Date: Tue, 12 Dec 2017 16:27:57 +0800 Message-Id: <1513067277-23126-1-git-send-email-baijiaju1990@163.com> X-Mailer: git-send-email 1.7.9.5 X-CM-TRANSID: DcCowABnfYJ+ki9aqUIlAg--.2212S2 X-Coremail-Antispam: 1Uf129KBjvdXoW7Jry7KrWfGryrGw15WFy7GFg_yoWkurc_WF WSyr17Ar4akF4Dtr1xCrWayFZF9a1UZFn0kw4Fga4fA3yDGw43Gr1DXrnrZrn3Xr43AFyk A390qryFvr1jkjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUbPl1PUUUUU== X-Originating-IP: [166.111.70.15] X-CM-SenderInfo: xedlyx5dmximizq6il2tof0z/1tbiGAOselXlcxmVDQAAsP Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The driver may sleep in the interrupt handler. The function call path is: esas2r_adapter_tasklet (interrupt handler) esas2r_do_tasklet_tasks esas2r_handle_chip_rst_during_tasklet esas2r_init_adapter_hw esas2r_init_msgs esas2r_wait_request schedule_timeout_interruptible --> may sleep To fix it, schedule_timeout_uninterruptible is replaced with mdelay. This bug is found by my static analysis tool(DSAC) and checked by my code review. Signed-off-by: Jia-Ju Bai --- drivers/scsi/esas2r/esas2r_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c index 4eb1430..4cd8f79 100644 --- a/drivers/scsi/esas2r/esas2r_main.c +++ b/drivers/scsi/esas2r/esas2r_main.c @@ -1307,7 +1307,7 @@ void esas2r_wait_request(struct esas2r_adapter *a, struct esas2r_request *rq) if (rq->req_stat != RS_STARTED) break; - schedule_timeout_interruptible(msecs_to_jiffies(100)); + mdelay(100); if ((jiffies_to_msecs(jiffies) - starttime) > timeout) { esas2r_hdebug("request TMO");