From patchwork Tue Dec 12 08:09:14 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: 10106433 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 977BD6032B for ; Tue, 12 Dec 2017 08:07:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8987A29834 for ; Tue, 12 Dec 2017 08:07:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7BE8C29AF7; Tue, 12 Dec 2017 08:07:17 +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.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI 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 146E229834 for ; Tue, 12 Dec 2017 08:07:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752048AbdLLIHO (ORCPT ); Tue, 12 Dec 2017 03:07:14 -0500 Received: from m12-11.163.com ([220.181.12.11]:40101 "EHLO m12-11.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751678AbdLLIHN (ORCPT ); Tue, 12 Dec 2017 03:07:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=1SPM1VnHwiVOmBexpR DAXCc1CVhAJ1frmvNlTpTC5aU=; b=la6wfCH4IpOPjB9XNVGWlc8rRUbI6743qT vGAzhgqFmv47j1wlwcFgZpo0B6Xh0WD5KjLEqTOezB8Z+yNlpKtj5gha11krNWBs jbONd6RnxNLMsSCfG3j29zG0L1N4gTY0cfO0MSTJ9gCACssrJoQrG/P550aBxl8f 0Oy78BDDc= Received: from bai-oslab.tsinghua.edu.cn (unknown [166.111.70.15]) by smtp7 (Coremail) with SMTP id C8CowADnmxgeji9agrCqBg--.25698S2; Tue, 12 Dec 2017 16:06:57 +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 possible sleep-in-atomic bugs in esas2r_check_adapter Date: Tue, 12 Dec 2017 16:09:14 +0800 Message-Id: <1513066154-22571-1-git-send-email-baijiaju1990@163.com> X-Mailer: git-send-email 1.7.9.5 X-CM-TRANSID: C8CowADnmxgeji9agrCqBg--.25698S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxJr1fCr4rAF43Cry7uFy8Zrb_yoW8Wr47pa yvkw1UXF48ZF4Sqw4UCF45ZF1rta1fGFW7X3WUZ395C3Z5tFs8XFs0yry2yFsxGrWkZ3Wa gFnYqw13G3WUJ3JanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UQ18PUUUUU= X-Originating-IP: [166.111.70.15] X-CM-SenderInfo: xedlyx5dmximizq6il2tof0z/1tbiYwGselaDwGO8RwAAs5 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_check_adapter schedule_timeout_interruptible 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_init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/esas2r/esas2r_init.c b/drivers/scsi/esas2r/esas2r_init.c index 5b14dd2..0b9f547 100644 --- a/drivers/scsi/esas2r/esas2r_init.c +++ b/drivers/scsi/esas2r/esas2r_init.c @@ -1068,7 +1068,7 @@ bool esas2r_check_adapter(struct esas2r_adapter *a) break; } - schedule_timeout_interruptible(msecs_to_jiffies(100)); + mdelay(100); if ((jiffies_to_msecs(jiffies) - starttime) > 180000) { esas2r_hdebug("FW ready TMO"); @@ -1091,7 +1091,7 @@ bool esas2r_check_adapter(struct esas2r_adapter *a) break; } - schedule_timeout_interruptible(msecs_to_jiffies(50)); + mdelay(50); if ((jiffies_to_msecs(jiffies) - starttime) > 3000) { esas2r_hdebug("timeout waiting for interface down"); @@ -1180,7 +1180,7 @@ bool esas2r_check_adapter(struct esas2r_adapter *a) break; } - schedule_timeout_interruptible(msecs_to_jiffies(100)); + mdelay(100); if ((jiffies_to_msecs(jiffies) - starttime) > 3000) { esas2r_hdebug(