[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20180620025801.30956-1-baijiaju1990@gmail.com>
Date: Wed, 20 Jun 2018 10:58:01 +0800
From: Jia-Ju Bai <baijiaju1990@...il.com>
To: gregkh@...uxfoundation.org, Larry.Finger@...inger.net,
garsilva@...eddedor.com, pkshih@...ltek.com
Cc: devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org,
Jia-Ju Bai <baijiaju1990@...il.com>
Subject: [PATCH] staging: rtlwifi: Fix a possible sleep-in-atomic-context bug in _is_fw_read_cmd_down()
The driver may sleep with holding a spinlock.
The function call path (from bottom to top) in Linux-4.16.7 is:
[FUNC] schedule
drivers/staging/rtlwifi/halmac/rtl_halmac.c, 884:
schedule in _is_fw_read_cmd_down
drivers/staging/rtlwifi/halmac/rtl_halmac.c, 912:
_is_fw_read_cmd_down in rtl_halmac_send_h2c
drivers/staging/rtlwifi/halmac/rtl_halmac.c, 907:
_raw_spin_lock_irqsave in rtl_halmac_send_h2c
To fix this bug, schedule() is replaced with mdelay(1).
This bug is found by my static analysis tool (DSAC-2) and checked by
my code review.
Signed-off-by: Jia-Ju Bai <baijiaju1990@...il.com>
---
drivers/staging/rtlwifi/halmac/rtl_halmac.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/rtlwifi/halmac/rtl_halmac.c b/drivers/staging/rtlwifi/halmac/rtl_halmac.c
index 66f0a6dfc52c..e921a62e72a3 100644
--- a/drivers/staging/rtlwifi/halmac/rtl_halmac.c
+++ b/drivers/staging/rtlwifi/halmac/rtl_halmac.c
@@ -881,7 +881,7 @@ static bool _is_fw_read_cmd_down(struct rtl_priv *rtlpriv, u8 msgbox_num)
if (valid == 0)
read_down = true;
else
- schedule();
+ mdelay(1);
} while ((!read_down) && (retry_cnts--));
return read_down;
--
2.17.0
Powered by blists - more mailing lists