aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorØrjan Eide2012-12-05 09:38:08 -0600
committerArve Hjønnevåg2013-02-19 19:56:16 -0600
commit0366d8bd917ee268c06accb2e082ac9d003e525e (patch)
treeab169a4c4aad95c8901aec132e8f5ba78f915631
parentab946e523af3e630c4433939544465e725769857 (diff)
downloadkernel-common-0366d8bd917ee268c06accb2e082ac9d003e525e.tar.gz
kernel-common-0366d8bd917ee268c06accb2e082ac9d003e525e.tar.xz
kernel-common-0366d8bd917ee268c06accb2e082ac9d003e525e.zip
sync: Fix race condition between merge and signal
The copied sync_pt was activated immediately. If the sync_pt was signaled before the entire merge was completed, the new fence's pt_list could be iterated over while it is still in the process of being created. Moving the the sync_pt_activate call for all new sync_pts to after both the sync_fence_copy_pts and the sync_fence_merge_pts calls ensure that the pt_list is complete and immutable before it can be reached from the timeline's active list. Signed-off-by: Erik Gilling <konkers@android.com>
-rw-r--r--drivers/base/sync.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/base/sync.c b/drivers/base/sync.c
index 809d02b21e0..a97a503f013 100644
--- a/drivers/base/sync.c
+++ b/drivers/base/sync.c
@@ -324,7 +324,6 @@ static int sync_fence_copy_pts(struct sync_fence *dst, struct sync_fence *src)
324 324
325 new_pt->fence = dst; 325 new_pt->fence = dst;
326 list_add(&new_pt->pt_list, &dst->pt_list_head); 326 list_add(&new_pt->pt_list, &dst->pt_list_head);
327 sync_pt_activate(new_pt);
328 } 327 }
329 328
330 return 0; 329 return 0;
@@ -356,7 +355,6 @@ static int sync_fence_merge_pts(struct sync_fence *dst, struct sync_fence *src)
356 new_pt->fence = dst; 355 new_pt->fence = dst;
357 list_replace(&dst_pt->pt_list, 356 list_replace(&dst_pt->pt_list,
358 &new_pt->pt_list); 357 &new_pt->pt_list);
359 sync_pt_activate(new_pt);
360 sync_pt_free(dst_pt); 358 sync_pt_free(dst_pt);
361 } 359 }
362 collapsed = true; 360 collapsed = true;
@@ -372,7 +370,6 @@ static int sync_fence_merge_pts(struct sync_fence *dst, struct sync_fence *src)
372 370
373 new_pt->fence = dst; 371 new_pt->fence = dst;
374 list_add(&new_pt->pt_list, &dst->pt_list_head); 372 list_add(&new_pt->pt_list, &dst->pt_list_head);
375 sync_pt_activate(new_pt);
376 } 373 }
377 } 374 }
378 375
@@ -453,6 +450,7 @@ struct sync_fence *sync_fence_merge(const char *name,
453 struct sync_fence *a, struct sync_fence *b) 450 struct sync_fence *a, struct sync_fence *b)
454{ 451{
455 struct sync_fence *fence; 452 struct sync_fence *fence;
453 struct list_head *pos;
456 int err; 454 int err;
457 455
458 fence = sync_fence_alloc(name); 456 fence = sync_fence_alloc(name);
@@ -467,6 +465,12 @@ struct sync_fence *sync_fence_merge(const char *name,
467 if (err < 0) 465 if (err < 0)
468 goto err; 466 goto err;
469 467
468 list_for_each(pos, &fence->pt_list_head) {
469 struct sync_pt *pt =
470 container_of(pos, struct sync_pt, pt_list);
471 sync_pt_activate(pt);
472 }
473
470 /* 474 /*
471 * signal the fence in case one of it's pts were activated before 475 * signal the fence in case one of it's pts were activated before
472 * they were activated 476 * they were activated