diff mbox series

[1/2] libmultipath: cleanup pthread_cleanup_pop call

Message ID 1543385604-25453-1-git-send-email-bmarzins@redhat.com (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show
Series [1/2] libmultipath: cleanup pthread_cleanup_pop call | expand

Commit Message

Benjamin Marzinski Nov. 28, 2018, 6:13 a.m. UTC
pthread_cleanup_push() and pthread_cleanup_pop() must be called in the
same lexical scope.  In uevent_listen(), the pthread_cleanup_pop() call
to cleanup the udev monitor is called in a nested 'if' block, within
the block where pthread_cleanup_push() is called.  Since this is a
single-statement if block, it doesn't actually cause any problems, but
it should be fixed anyways.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 libmultipath/uevent.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Martin Wilck Nov. 28, 2018, 9:02 a.m. UTC | #1
On Wed, 2018-11-28 at 00:13 -0600,  Benjamin Marzinski  wrote:
> pthread_cleanup_push() and pthread_cleanup_pop() must be called in
> the
> same lexical scope.  In uevent_listen(), the pthread_cleanup_pop()
> call
> to cleanup the udev monitor is called in a nested 'if' block, within
> the block where pthread_cleanup_push() is called.  Since this is a
> single-statement if block, it doesn't actually cause any problems,
> but
> it should be fixed anyways.
> 
> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>


--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
diff mbox series

Patch

diff --git a/libmultipath/uevent.c b/libmultipath/uevent.c
index 5f910e6..f73de8c 100644
--- a/libmultipath/uevent.c
+++ b/libmultipath/uevent.c
@@ -806,7 +806,7 @@  int uevent_listen(struct udev *udev)
 	monitor = udev_monitor_new_from_netlink(udev, "udev");
 	if (!monitor) {
 		condlog(2, "failed to create udev monitor");
-		goto out;
+		goto failback;
 	}
 	pthread_cleanup_push(monitor_cleanup, monitor);
 #ifdef LIBUDEV_API_RECVBUF
@@ -893,8 +893,8 @@  int uevent_listen(struct udev *udev)
 	}
 	need_failback = 0;
 out:
-	if (monitor)
-		pthread_cleanup_pop(1);
+	pthread_cleanup_pop(1);
+failback:
 	if (need_failback)
 		err = failback_listen();
 	pthread_cleanup_pop(1);