[PATCH 2/3] libmultipath: is_uevent_busy(): check servicing_uev under lock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Martin Wilck <mwilck@xxxxxxxx>

This fixes a coverity-reported defect (413384 Data race condition).
Indeed, we always set servicing_uev with the lock held, so it makes
sense to read it with the lock held, too.

Signed-off-by: Martin Wilck <mwilck@xxxxxxxx>
---
 libmultipath/uevent.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libmultipath/uevent.c b/libmultipath/uevent.c
index 3b5dd31..32135d7 100644
--- a/libmultipath/uevent.c
+++ b/libmultipath/uevent.c
@@ -82,12 +82,13 @@ static void reset_filter_state(struct uevent_filter_state *st)
 
 int is_uevent_busy(void)
 {
-	int empty;
+	int empty, servicing;
 
 	pthread_mutex_lock(uevq_lockp);
 	empty = list_empty(&uevq);
+	servicing = servicing_uev;
 	pthread_mutex_unlock(uevq_lockp);
-	return (!empty || servicing_uev);
+	return (!empty || servicing);
 }
 
 struct uevent * alloc_uevent (void)
-- 
2.43.0





[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux