LKML Archive on
help / color / mirror / Atom feed
From: Jia-Ju Bai <>
	Jia-Ju Bai <>
Subject: [PATCH] ata: ata_piix: Fix a possible data race in piix_pci_device_resume
Date: Tue,  8 May 2018 11:46:13 +0800	[thread overview]
Message-ID: <> (raw)

The write operation to "host->flags" is protected by
the lock on line 1048, but the read operation to
this data on line 1046 is not protected by the lock.
Thus, there may exist a data race for "host->flags".

To fix this data race, the read operation to "host->flags" 
should be also protected by the lock.

Signed-off-by: Jia-Ju Bai <>
 drivers/ata/ata_piix.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 7ecb1322a514..c99fdf473dee 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -1043,8 +1043,8 @@ static int piix_pci_device_resume(struct pci_dev *pdev)
 	unsigned long flags;
 	int rc;
+	spin_lock_irqsave(&host->lock, flags);
 	if (host->flags & PIIX_HOST_BROKEN_SUSPEND) {
-		spin_lock_irqsave(&host->lock, flags);
 		host->flags &= ~PIIX_HOST_BROKEN_SUSPEND;
 		spin_unlock_irqrestore(&host->lock, flags);
@@ -1060,8 +1060,10 @@ static int piix_pci_device_resume(struct pci_dev *pdev)
 				"failed to enable device after resume (%d)\n",
-	} else
+	} else {
+		spin_unlock_irqrestore(&host->lock, flags);
 		rc = ata_pci_device_do_resume(pdev);
+	}
 	if (rc == 0)

             reply	other threads:[~2018-05-08  3:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-08  3:46 Jia-Ju Bai [this message]
2018-05-08 14:20 ` Tejun Heo

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \
    --subject='Re: [PATCH] ata: ata_piix: Fix a possible data race in piix_pci_device_resume' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).