Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752646AbdLMJ7A (ORCPT ); Wed, 13 Dec 2017 04:59:00 -0500 Received: from mail-it0-f68.google.com ([209.85.214.68]:33246 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752447AbdLMJ6y (ORCPT ); Wed, 13 Dec 2017 04:58:54 -0500 X-Google-Smtp-Source: ACJfBovvt6U8WlI0BcjIBuD6QDAk4sINtU+NGjMEHHT6HrJP1oEVd6LUlak/X5+jt5KzLYOC8hDcbg== From: Jia-Ju Bai To: Dept-GELinuxNICDev@cavium.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH 1/2] qla3xxx: Fix a possible sleep-in-atomic bug in ql_sem_spinlock Date: Wed, 13 Dec 2017 18:01:13 +0800 Message-Id: <1513159273-14739-1-git-send-email-baijiaju1990@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1000 Lines: 34 The driver may sleep under a spinlock. The function call paths are: ql_get_full_dup (acquire the spinlock) ql_sem_spinlock ssleep --> may sleep ql_get_auto_cfg_status (acquire the spinlock) ql_sem_spinlock ssleep --> may sleep To fix it, ssleep 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/net/ethernet/qlogic/qla3xxx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/qlogic/qla3xxx.c b/drivers/net/ethernet/qlogic/qla3xxx.c index 9e5264d..8ad3e24 100644 --- a/drivers/net/ethernet/qlogic/qla3xxx.c +++ b/drivers/net/ethernet/qlogic/qla3xxx.c @@ -115,7 +115,7 @@ static int ql_sem_spinlock(struct ql3_adapter *qdev, value = readl(&port_regs->CommonRegs.semaphoreReg); if ((value & (sem_mask >> 16)) == sem_bits) return 0; - ssleep(1); + mdelay(1000); } while (--seconds); return -1; } -- 1.7.9.5