All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t] tests/drm_import_export: Always loop with mutex held
@ 2015-11-25 13:20 Mika Kuoppala
  2015-11-25 13:38 ` Winiarski, Michal
  0 siblings, 1 reply; 2+ messages in thread
From: Mika Kuoppala @ 2015-11-25 13:20 UTC (permalink / raw)
  To: intel-gfx; +Cc: Thomas Wood

We assume that lock is held on start of the loop scope.
Some paths continuing inside loop didn't adhere to this
assumption, causing segfault on unlocking an already
unlocked mutex. Fix this by re-aquiring lock always.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93013
Cc: Michał Winiarski <michal.winiarski@intel.com>
Cc: Thomas Wood <thomas.wood@intel.com>
Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
---
 tests/drm_import_export.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/drm_import_export.c b/tests/drm_import_export.c
index 49486ab..cfe5f6d 100644
--- a/tests/drm_import_export.c
+++ b/tests/drm_import_export.c
@@ -161,20 +161,20 @@ static void *import_close_thread(void *data)
 				pthread_mutex_unlock(&t->mutex);
 			}
 			else
-				/* We take the lock right after entering the loop */
+				/* Lock should be held on entering the loop */
 				continue;
 		}
+
 		if (bo == NULL) {
 			/*
 			 * If the bo is NULL it means that we've unreferenced in other
 			 * thread - therefore we should expect ENOENT
 			 */
 			igt_assert_eq(errno, ENOENT);
-			continue;
+		} else {
+			drm_intel_bo_unreference(bo);
 		}
 
-		drm_intel_bo_unreference(bo);
-
 		pthread_mutex_lock(&t->mutex);
 	}
 	pthread_mutex_unlock(&t->mutex);
-- 
2.5.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH i-g-t] tests/drm_import_export: Always loop with mutex held
  2015-11-25 13:20 [PATCH i-g-t] tests/drm_import_export: Always loop with mutex held Mika Kuoppala
@ 2015-11-25 13:38 ` Winiarski, Michal
  0 siblings, 0 replies; 2+ messages in thread
From: Winiarski, Michal @ 2015-11-25 13:38 UTC (permalink / raw)
  To: mika.kuoppala@linux.intel.com, intel-gfx@lists.freedesktop.org
  Cc: Wood, Thomas

On Wed, 2015-11-25 at 15:20 +0200, Mika Kuoppala wrote:
> We assume that lock is held on start of the loop scope.
> Some paths continuing inside loop didn't adhere to this
> assumption, causing segfault on unlocking an already
> unlocked mutex. Fix this by re-aquiring lock always.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93013
> Cc: Michał Winiarski <michal.winiarski@intel.com>
> Cc: Thomas Wood <thomas.wood@intel.com>
> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>

Reviewed-by: Michał Winiarski <michal.winiarski@intel.com>

> ---
>  tests/drm_import_export.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/drm_import_export.c b/tests/drm_import_export.c
> index 49486ab..cfe5f6d 100644
> --- a/tests/drm_import_export.c
> +++ b/tests/drm_import_export.c
> @@ -161,20 +161,20 @@ static void *import_close_thread(void *data)
>  				pthread_mutex_unlock(&t->mutex);
>  			}
>  			else
> -				/* We take the lock right after
> entering the loop */
> +				/* Lock should be held on entering
> the loop */
>  				continue;
>  		}
> +
>  		if (bo == NULL) {
>  			/*
>  			 * If the bo is NULL it means that we've
> unreferenced in other
>  			 * thread - therefore we should expect
> ENOENT
>  			 */
>  			igt_assert_eq(errno, ENOENT);
> -			continue;
> +		} else {
> +			drm_intel_bo_unreference(bo);
>  		}
>  
> -		drm_intel_bo_unreference(bo);
> -
>  		pthread_mutex_lock(&t->mutex);
>  	}
>  	pthread_mutex_unlock(&t->mutex);
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-11-25 13:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-25 13:20 [PATCH i-g-t] tests/drm_import_export: Always loop with mutex held Mika Kuoppala
2015-11-25 13:38 ` Winiarski, Michal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.