* [PATCH] ata: libata-pmp: Fix a possible data race in sata_pmp_handle_link_fail
@ 2018-05-08 8:21 Jia-Ju Bai
2018-05-08 14:20 ` Tejun Heo
0 siblings, 1 reply; 2+ messages in thread
From: Jia-Ju Bai @ 2018-05-08 8:21 UTC (permalink / raw)
To: tj; +Cc: linux-ide, linux-kernel, Jia-Ju Bai
The write operation to "link->flags" is protected by
the lock on line 898, but the read operation to
this data on line 892 is not protected by the lock.
Thus, there may exist a data race for "link->flags".
To fix this data race, the read operation to "link->flags"
should be also protected by the lock.
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
drivers/ata/libata-pmp.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/ata/libata-pmp.c b/drivers/ata/libata-pmp.c
index 85aa76116a30..42f61106ac70 100644
--- a/drivers/ata/libata-pmp.c
+++ b/drivers/ata/libata-pmp.c
@@ -889,15 +889,14 @@ static int sata_pmp_handle_link_fail(struct ata_link *link, int *link_tries)
return 1;
/* disable this link */
+ spin_lock_irqsave(ap->lock, flags);
if (!(link->flags & ATA_LFLAG_DISABLED)) {
ata_link_warn(link,
"failed to recover link after %d tries, disabling\n",
ATA_EH_PMP_LINK_TRIES);
-
- spin_lock_irqsave(ap->lock, flags);
link->flags |= ATA_LFLAG_DISABLED;
- spin_unlock_irqrestore(ap->lock, flags);
}
+ spin_unlock_irqrestore(ap->lock, flags);
ata_dev_disable(link->device);
link->eh_context.i.action = 0;
--
2.17.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] ata: libata-pmp: Fix a possible data race in sata_pmp_handle_link_fail
2018-05-08 8:21 [PATCH] ata: libata-pmp: Fix a possible data race in sata_pmp_handle_link_fail Jia-Ju Bai
@ 2018-05-08 14:20 ` Tejun Heo
0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2018-05-08 14:20 UTC (permalink / raw)
To: Jia-Ju Bai; +Cc: linux-ide, linux-kernel
On Tue, May 08, 2018 at 04:21:40PM +0800, Jia-Ju Bai wrote:
> The write operation to "link->flags" is protected by
> the lock on line 898, but the read operation to
> this data on line 892 is not protected by the lock.
> Thus, there may exist a data race for "link->flags".
>
> To fix this data race, the read operation to "link->flags"
> should be also protected by the lock.
Same as the previous patch.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-05-08 14:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-08 8:21 [PATCH] ata: libata-pmp: Fix a possible data race in sata_pmp_handle_link_fail Jia-Ju Bai
2018-05-08 14:20 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome