Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753506AbdFSCqZ (ORCPT ); Sun, 18 Jun 2017 22:46:25 -0400 Received: from m12-14.163.com ([220.181.12.14]:46686 "EHLO m12-14.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753298AbdFSCqX (ORCPT ); Sun, 18 Jun 2017 22:46:23 -0400 From: Jia-Ju Bai To: manish.chopra@cavium.com, rahul.verma@cavium.com, davem@davemloft.net Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] netxen: Fix a sleep-in-atomic bug in netxen_nic_pci_mem_access_direct Date: Mon, 19 Jun 2017 10:48:53 +0800 Message-Id: <1497840533-4894-1-git-send-email-baijiaju1990@163.com> X-Mailer: git-send-email 1.7.9.5 X-CM-TRANSID: DsCowAB3FJHaOkdZ_Y34MQ--.1647S2 X-Coremail-Antispam: 1Uf129KBjvdXoW7XryfCw18tFy5ZFW3CFykZrb_yoWDKrXEgF sYgF1fX3y5Zr1Ykay2yr4fZryIkrZrXr9Ykry7tFW3Zr90vFyYkrykAF18A3yag3yfJa47 GF13tryrZ34IqjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUj75r3UUUUU== X-Originating-IP: [166.111.70.19] X-CM-SenderInfo: xedlyx5dmximizq6il2tof0z/1tbiTgL7elUCyd3G4AAAso Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1037 Lines: 29 The driver may sleep under a spin lock, and the function call path is: netxen_nic_pci_mem_access_direct (acquire the lock by spin_lock) ioremap --> may sleep To fix it, the lock is released before "ioremap", and the lock is acquired again after this function. Signed-off-by: Jia-Ju Bai --- drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c index a996801..5ea553e 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c @@ -1419,7 +1419,9 @@ static u32 netxen_nic_io_read_2M(struct netxen_adapter *adapter, mem_base = pci_resource_start(adapter->pdev, 0) + (start & PAGE_MASK); + spin_unlock(&adapter->ahw.mem_lock); mem_ptr = ioremap(mem_base, PAGE_SIZE); + spin_lock(&adapter->ahw.mem_lock); if (mem_ptr == NULL) { ret = -EIO; goto unlock; -- 1.7.9.5