diff mbox series

rt-tests: pi_stress: Move unlock into if block with matching lock

Message ID 20240923155343.43720-1-jwyatt@redhat.com
State New
Headers show
Series rt-tests: pi_stress: Move unlock into if block with matching lock | expand

Commit Message

John B. Wyatt IV Sept. 23, 2024, 3:53 p.m. UTC
Resolve unlocking a not locked mutex.

Issue reported by Valgrind's Helgrind tool.

Signed-off-by: John B. Wyatt IV <jwyatt@redhat.com>
Signed-off-by: John B. Wyatt IV <sageofredondo@gmail.com>
---
 src/pi_tests/pi_stress.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

John Kacur Sept. 25, 2024, 5:47 p.m. UTC | #1
On Mon, 23 Sep 2024, John B. Wyatt IV wrote:

> Resolve unlocking a not locked mutex.
> 
> Issue reported by Valgrind's Helgrind tool.
> 
> Signed-off-by: John B. Wyatt IV <jwyatt@redhat.com>
> Signed-off-by: John B. Wyatt IV <sageofredondo@gmail.com>
> ---
>  src/pi_tests/pi_stress.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/pi_tests/pi_stress.c b/src/pi_tests/pi_stress.c
> index 673a7bb..371e906 100644
> --- a/src/pi_tests/pi_stress.c
> +++ b/src/pi_tests/pi_stress.c
> @@ -552,8 +552,8 @@ void *reporter(void *arg __attribute__ ((unused)))
>  				printf("Current Inversions: %lu\n",
>  						total_inversions());
>  			}
> +			pthread_mutex_unlock(&shutdown_mtx);
>  		}
> -		pthread_mutex_unlock(&shutdown_mtx);
>  
>  		/* if we specified a duration, see if it has expired */
>  		if (end && time(NULL) > end) {
> -- 
> 2.46.0
> 
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>
diff mbox series

Patch

diff --git a/src/pi_tests/pi_stress.c b/src/pi_tests/pi_stress.c
index 673a7bb..371e906 100644
--- a/src/pi_tests/pi_stress.c
+++ b/src/pi_tests/pi_stress.c
@@ -552,8 +552,8 @@  void *reporter(void *arg __attribute__ ((unused)))
 				printf("Current Inversions: %lu\n",
 						total_inversions());
 			}
+			pthread_mutex_unlock(&shutdown_mtx);
 		}
-		pthread_mutex_unlock(&shutdown_mtx);
 
 		/* if we specified a duration, see if it has expired */
 		if (end && time(NULL) > end) {