diff mbox series

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

Message ID 20240105184037.16518-3-mwilck@suse.com (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show
Series multipath-tools: coverity defect fixes | expand

Commit Message

Martin Wilck Jan. 5, 2024, 6:40 p.m. UTC
From: Martin Wilck <mwilck@suse.com>

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@suse.com>
---
 libmultipath/uevent.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

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)