diff options
author | Tuomas Tynkkynen <ttynkkynen@nvidia.com> | 2012-08-17 11:37:02 +0300 |
---|---|---|
committer | Simone Willett <swillett@nvidia.com> | 2012-08-22 17:23:55 -0700 |
commit | a39320fc45e9657c0d90c97a73fb89d5395cefd3 (patch) | |
tree | a3bec4abd71bd0998cd723480c2e8b3a49db0599 /arch/arm/mach-tegra/iovmm.c | |
parent | e0ed318ccce39543fa821d3cef901111bae556a0 (diff) |
ARM: tegra: iovmm: Fix spinlock bug if alloc fails
iovmm_split_free_block leaves the domain's spinlock unlocked if a
memory allocation failed. Unfortunately, all the callers of that
function assume that it takes the spinlock. This will then lead to
double unlocking of the spinlock.
Bug 1035105
Change-Id: Ib4379cad76f053586d6a77b8d0dc9f41af01931a
Signed-off-by: Tuomas Tynkkynen <ttynkkynen@nvidia.com>
Reviewed-on: http://git-master/r/124299
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
Diffstat (limited to 'arch/arm/mach-tegra/iovmm.c')
-rw-r--r-- | arch/arm/mach-tegra/iovmm.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/arch/arm/mach-tegra/iovmm.c b/arch/arm/mach-tegra/iovmm.c index 86a92aec2d28..488c6a6fc828 100644 --- a/arch/arm/mach-tegra/iovmm.c +++ b/arch/arm/mach-tegra/iovmm.c @@ -255,11 +255,13 @@ static struct tegra_iovmm_block *iovmm_split_free_block( struct tegra_iovmm_block *rem; struct tegra_iovmm_block *b; + spin_unlock(&domain->block_lock); rem = kmem_cache_zalloc(iovmm_cache, GFP_KERNEL); + spin_lock(&domain->block_lock); + if (!rem) return NULL; - spin_lock(&domain->block_lock); p = &domain->free_blocks.rb_node; rem->start = block->start + size; @@ -344,7 +346,6 @@ static struct tegra_iovmm_block *iovmm_alloc_block( simalign = SIMALIGN(best, align); if (DO_SPLIT(simalign)) { iovmm_block_splitting = 1; - spin_unlock(&domain->block_lock); /* Split off misalignment */ b = best; @@ -365,7 +366,6 @@ static struct tegra_iovmm_block *iovmm_alloc_block( if (DO_SPLIT((best->start + best->length) - iovmm_end(best))) { iovmm_block_splitting = 1; - spin_unlock(&domain->block_lock); /* Split off excess */ (void)iovmm_split_free_block(domain, best, size + simalign); @@ -415,7 +415,6 @@ static struct tegra_iovmm_block *iovmm_allocate_vm( /* split the mem before iovm_start. */ if (DO_SPLIT(iovm_start - best->start)) { iovmm_block_splitting = 1; - spin_unlock(&domain->block_lock); best = iovmm_split_free_block(domain, best, (iovm_start - best->start)); } @@ -435,7 +434,6 @@ static struct tegra_iovmm_block *iovmm_allocate_vm( /* split the mem after iovm_start+size. */ if (DO_SPLIT(best->start + best->length - iovmm_end(best))) { iovmm_block_splitting = 1; - spin_unlock(&domain->block_lock); (void)iovmm_split_free_block(domain, best, (iovmm_start(best) - best->start + size)); } |