From: Jia-Ju Bai <baijiaju1990@gmail.com>
To: lidza.louina@gmail.com, markh@compro.net, gregkh@linuxfoundation.org
Cc: driverdev-devel@linuxdriverproject.org,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
Jia-Ju Bai <baijiaju1990@gmail.com>
Subject: [PATCH] staging: dgnc: Fix a sleep-in-atomic-context bug in cls_assert_modem_signals()
Date: Sat, 15 Sep 2018 11:13:03 +0800 [thread overview]
Message-ID: <20180915031303.5302-1-baijiaju1990@gmail.com> (raw)
The driver may sleep with holding a spinlock.
The function call path (from bottom to top) in Linux-4.17 is:
[FUNC] usleep_range
drivers/staging/dgnc/dgnc_cls.c, 391:
usleep_range in cls_assert_modem_signals
drivers/staging/dgnc/dgnc_cls.c, 449:
cls_assert_modem_signals in cls_copy_data_from_queue_to_uart
drivers/staging/dgnc/dgnc_cls.c, 406:
_raw_spin_lock_irqsave in cls_copy_data_from_queue_to_uart
To fix this bug, usleep_range() is replaced with udelay().
This bug is found by my static analysis tool DSAC.
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
drivers/staging/dgnc/dgnc_cls.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/dgnc/dgnc_cls.c b/drivers/staging/dgnc/dgnc_cls.c
index 7e6cbfe4e4ee..a1e98ee7f9e0 100644
--- a/drivers/staging/dgnc/dgnc_cls.c
+++ b/drivers/staging/dgnc/dgnc_cls.c
@@ -388,7 +388,7 @@ static void cls_assert_modem_signals(struct channel_t *ch)
writeb(out, &ch->ch_cls_uart->mcr);
/* Give time for the UART to actually drop the signals */
- usleep_range(10, 20);
+ udelay(20);
}
static void cls_copy_data_from_queue_to_uart(struct channel_t *ch)
--
2.17.0
reply other threads:[~2018-09-15 3:13 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180915031303.5302-1-baijiaju1990@gmail.com \
--to=baijiaju1990@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=driverdev-devel@linuxdriverproject.org \
--cc=gregkh@linuxfoundation.org \
--cc=lidza.louina@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=markh@compro.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®