From: Takashi Iwai <tiwai@suse.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ata: Fix racy link clearance
Date: Wed, 14 Nov 2018 15:40:50 +0100 [thread overview]
Message-ID: <20181114144050.12630-1-tiwai@suse.de> (raw)
The ap->sff_pio_task_link gets cleared in a racy way in
ata_sff_flush_pio_task(). This may lead to BUG_ON() check in the
work, and screw up the whole system.
Along with it, replace BUG_ON() with WARN_ON() and let the work quit
gracefully. It's no end of the world, after all.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
drivers/ata/libata-sff.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index c5ea0fc635e5..28ef46ef656d 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -1271,9 +1271,8 @@ void ata_sff_flush_pio_task(struct ata_port *ap)
*/
spin_lock_irq(ap->lock);
ap->hsm_task_state = HSM_ST_IDLE;
- spin_unlock_irq(ap->lock);
-
ap->sff_pio_task_link = NULL;
+ spin_unlock_irq(ap->lock);
if (ata_msg_ctl(ap))
ata_port_dbg(ap, "%s: EXIT\n", __func__);
@@ -1283,14 +1282,17 @@ static void ata_sff_pio_task(struct work_struct *work)
{
struct ata_port *ap =
container_of(work, struct ata_port, sff_pio_task.work);
- struct ata_link *link = ap->sff_pio_task_link;
+ struct ata_link *link;
struct ata_queued_cmd *qc;
u8 status;
int poll_next;
spin_lock_irq(ap->lock);
- BUG_ON(ap->sff_pio_task_link == NULL);
+ link = ap->sff_pio_task_link;
+ if (WARN_ON(!link))
+ goto out_unlock;
+
/* qc can be NULL if timeout occurred */
qc = ata_qc_from_tag(ap, link->active_tag);
if (!qc) {
--
2.19.1
reply other threads:[~2018-11-14 14:40 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=20181114144050.12630-1-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=axboe@kernel.dk \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).