Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Winiarski, Michal" <michal.winiarski@intel.com>
To: "mika.kuoppala@linux.intel.com" <mika.kuoppala@linux.intel.com>,
	"intel-gfx@lists.freedesktop.org"
	<intel-gfx@lists.freedesktop.org>
Cc: "Wood, Thomas" <thomas.wood@intel.com>
Subject: Re: [PATCH i-g-t] tests/drm_import_export: Always loop with mutex held
Date: Wed, 25 Nov 2015 13:38:05 +0000	[thread overview]
Message-ID: <1448458685.15494.2.camel@intel.com> (raw)
In-Reply-To: <1448457626-9959-1-git-send-email-mika.kuoppala@intel.com>

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

      reply	other threads:[~2015-11-25 13:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1448458685.15494.2.camel@intel.com \
    --to=michal.winiarski@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=mika.kuoppala@linux.intel.com \
    --cc=thomas.wood@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox