All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] qla3xxx: Fix a possible sleep-in-atomic bug in ql_sem_spinlock
@ 2017-12-13 10:01 Jia-Ju Bai
  0 siblings, 0 replies; only message in thread
From: Jia-Ju Bai @ 2017-12-13 10:01 UTC (permalink / raw)
  To: Dept-GELinuxNICDev; +Cc: netdev, linux-kernel, Jia-Ju Bai

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 <baijiaju1990@gmail.com>
---
 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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-12-13  9:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-13 10:01 [PATCH 1/2] qla3xxx: Fix a possible sleep-in-atomic bug in ql_sem_spinlock Jia-Ju Bai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.