Skip to content

Commit

Permalink
[ARM] omap: resource: Lock resource list in update_resource_level
Browse files Browse the repository at this point in the history
Take the resource mutex when iterating over the resource user_list.
A race can occur if resource_request() adds a first time user to
the user_list while update_resource_level() is called.

Change-Id: I41dfd93845347132ddc2ba8c32fdfa0e62aaefe2
Signed-off-by: Mike Chan <mike@android.com>
  • Loading branch information
Mike Chan committed Apr 8, 2010
1 parent 360cbb8 commit 1bced97
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions arch/arm/plat-omap/resource.c
Expand Up @@ -106,6 +106,7 @@ static int update_resource_level(struct shared_resource *resp)
unsigned long target_level;
int ret;

mutex_lock(&resp->resource_mutex);
/* Regenerate the target_value for the resource */
if (resp->flags & RES_TYPE_PERFORMANCE) {
target_level = RES_PERFORMANCE_DEFAULTLEVEL;
Expand All @@ -118,9 +119,11 @@ static int update_resource_level(struct shared_resource *resp)
if (user->level < target_level)
target_level = user->level;
} else {
mutex_unlock(&resp->resource_mutex);
pr_debug("SRF: Unknown resource type\n");
return -EINVAL;
}
mutex_unlock(&resp->resource_mutex);

pr_debug("SRF: Changing Level for resource %s to %ld\n",
resp->name, target_level);
Expand Down

0 comments on commit 1bced97

Please sign in to comment.