aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorØrjan Eide2012-12-05 09:38:08 -0600
committerArve Hjønnevåg2013-03-11 17:25:19 -0500
commitca4e3312db2de4153a0a4ccfee917488f365a0a7 (patch)
treedd0df90c6b187c5af056df7aafb01c54b22399cd
parentb3b929c324a7650e8838bc80555e99a6bb147c7e (diff)
downloadkernel-common-ca4e3312db2de4153a0a4ccfee917488f365a0a7.tar.gz
kernel-common-ca4e3312db2de4153a0a4ccfee917488f365a0a7.tar.xz
kernel-common-ca4e3312db2de4153a0a4ccfee917488f365a0a7.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