Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp339089imm; Sat, 1 Sep 2018 04:42:13 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYSfFo+Cyzu5VVJfVJKs0yPqCTcCjulSYV7S8eNvDMIN0oE6l2d5mqqw9xLegIgjgMwiEP1 X-Received: by 2002:a65:608b:: with SMTP id t11-v6mr3682072pgu.259.1535802133507; Sat, 01 Sep 2018 04:42:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535802133; cv=none; d=google.com; s=arc-20160816; b=GDb9GFmfMB9LYwsUPQzEP6ZFgHEr3x9TNgFu02eomxZdyryHP3ItocjvOtWIa4B8lD Vy9UjhqB8h6aED0/HnQmWwrNgiClmk0k7WVkJTdcziolWzpXaD7361HGG9rB8ZJEm58E uykWArvWwcQskuOivyIR1TgLpB4S3ixlRJe1y8wB4J00kI8o0+JNz5BerQSsgIWgvOMf uAna2sdj6tkGY743HkggGD+oY4aya4ukBM02N+sTnD4u1xbkgzlNOr47MPfBrGB7FHR0 WtLF3SgnYw+c0njpjze+PBEs6GX3hxeW6c432vqMYLUHC1L6A36A5rA5mfNwOOILMAZm uxcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=mi+hw9mk3Z/J7/fU0plW5Uvm7iOTyHvlmITO5aQv+dI=; b=rwo7DczB0/JVhIBAsntgO08JiSGNPdolOpZDte8UtqpSgUhV9zdaoN8mPk5TZRxc7K 7usd7rRPdPYH2ZB4pnmM3QumJ5v/tlAJHDx9fTC+PcemOb0/Uk41eaLNs67uhBknzXVp KEDxlTAdbcneGq+QrSlVTnrX98Xd3Y5RXVDDnNrHKtcRWhNqPQT8WYPZhJPOghA7lZyP kmi8EqwT7smyEQdxBHPWQ+b2eFbxu1N87y/GIpyqlB7rwYMZYtvZEJPCDne8jbJqLXdP 1jd1isnjIW4JlMRDOkdjb4T3zFc9pxq/AYUR2/7Mnh29ERcg4Alhk7clWhRsVSus/s6c BxGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QFClXFjK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 2-v6si12395580plb.444.2018.09.01.04.41.44; Sat, 01 Sep 2018 04:42:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QFClXFjK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727212AbeIAPvl (ORCPT + 99 others); Sat, 1 Sep 2018 11:51:41 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:36231 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726430AbeIAPvl (ORCPT ); Sat, 1 Sep 2018 11:51:41 -0400 Received: by mail-pf1-f194.google.com with SMTP id b11-v6so6688751pfo.3; Sat, 01 Sep 2018 04:39:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=mi+hw9mk3Z/J7/fU0plW5Uvm7iOTyHvlmITO5aQv+dI=; b=QFClXFjK50mb9brs7BGgPn11x8BzE/Jd/mhmKaEY9UWUXk4dCAnnWUrRKK9zEItZ28 0X8ZeA7yvK3JrC/tDNMivMad82is16xhvVG3JRin/nIQrbELN/A3zDsH/Rs4ZVdX/mpz bXyCS5Xy08pSJ9PH8dvSl6noucsWIEvnFc4wqMTUby5avmmkqDMYeJecHGs+oDLK65aq 6uKRkHZdYB2VJLKbGWzjKNbOa1Ae/MxZ1UEAMmlkeJ/k8sDomoedZrqMoZUiuf9HYpQI FCALpoVt0n+hfc1fkdzzmC6cfG8ndETBg0oZ3F/lDvwiI2QgK/jBa8vFRX/dA88Ws1P6 NP6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=mi+hw9mk3Z/J7/fU0plW5Uvm7iOTyHvlmITO5aQv+dI=; b=et0JmCT7RGh66TCB6wajyR7m/ATib4zcbmwtA2y2RQATrFpmRdxLlv8rc73nykSrIQ 0jXMxO3iUsHLlo/mhFimqLCMB1UHa1SDnff2fEsX9ZbOgDsNBZv/N5H8jp9VJ9TvZyq5 h01RRloovzSVjlcFdoljPsSDJDriJZ9CBrGo78AtHGJ8iO7BZ+x5AaUR9Q5wU5D2ev+7 kPCzsnKAMI6xLC2eSCJnEOJ59srHIwHTPaOLUwtJwxvDRWW44JjXZL7w9SxiB3+iNh8E /ZhC97ztklLftOfcse15hOPhHjlVtSUJ5PckNVrDD9IV0PIATH+rPJuA9wMBgmwT7Rm8 aW/g== X-Gm-Message-State: APzg51DoFkNjaQ0HO7VHs0i8V4eR+avSNzyDnxRzchnV5BETqD4RnfAi yVPinkZhzTH7WsoX06tNzGttwArz X-Received: by 2002:a65:6086:: with SMTP id t6-v6mr3604257pgu.424.1535801997449; Sat, 01 Sep 2018 04:39:57 -0700 (PDT) Received: from localhost.localdomain ([2402:f000:1:4414:2913:cd09:aee0:380]) by smtp.gmail.com with ESMTPSA id c78-v6sm21586620pfc.188.2018.09.01.04.39.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Sep 2018 04:39:57 -0700 (PDT) From: Jia-Ju Bai To: oulijun@huawei.com, xavier.huwei@huawei.com, dledford@redhat.com, jgg@ziepe.ca Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] infiniband: hw: hns: Fix a sleep-in-atomic-context bug in hns_roce_set_hem() Date: Sat, 1 Sep 2018 19:39:48 +0800 Message-Id: <20180901113948.28967-1-baijiaju1990@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The driver may sleep with holding a spinlock. The function call paths (from bottom to top) in Linux-4.16 are: drivers/infiniband/hw/hns/hns_roce_hem.c, 345: msleep in hns_roce_set_hem drivers/infiniband/hw/hns/hns_roce_hem.c, 330: _raw_spin_lock_irqsave in hns_roce_set_hem To fix this bug, msleep() is replaced with mdelay(). This bug is found by my static analysis tool DSAC. Signed-off-by: Jia-Ju Bai --- drivers/infiniband/hw/hns/hns_roce_hem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/hns/hns_roce_hem.c b/drivers/infiniband/hw/hns/hns_roce_hem.c index 63b5b3edabcb..8c142676c589 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hem.c +++ b/drivers/infiniband/hw/hns/hns_roce_hem.c @@ -342,7 +342,7 @@ static int hns_roce_set_hem(struct hns_roce_dev *hr_dev, } else { break; } - msleep(HW_SYNC_SLEEP_TIME_INTERVAL); + mdelay(HW_SYNC_SLEEP_TIME_INTERVAL); } bt_cmd_l = (u32)bt_ba; -- 2.17.0