diff options
author | Markus Elfring <elfring@users.sourceforge.net> | 2017-10-23 21:27:30 +0200 |
---|---|---|
committer | Lucas Stach <l.stach@pengutronix.de> | 2017-12-01 17:37:31 +0100 |
commit | ff9815957768b6e76d6895a0597d1ede05b4378b (patch) | |
tree | 7cd5a3575cb3cbfbe144b940c9c6993613a53b3b /drivers/gpu/drm/etnaviv | |
parent | b6047ebaf7b3fb63c3ad49ec9c381a0e0b9fb82a (diff) | |
download | lwn-ff9815957768b6e76d6895a0597d1ede05b4378b.tar.gz lwn-ff9815957768b6e76d6895a0597d1ede05b4378b.zip |
drm/etnaviv: Improve unlocking of a mutex in etnaviv_iommu_map_gem()
Add a jump target so that a call of the function "mutex_unlock" is stored
only once at the end of this function implementation.
Replace three calls by goto statements.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Diffstat (limited to 'drivers/gpu/drm/etnaviv')
-rw-r--r-- | drivers/gpu/drm/etnaviv/etnaviv_mmu.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_mmu.c b/drivers/gpu/drm/etnaviv/etnaviv_mmu.c index 35074b944778..d113fe06e6b5 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_mmu.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_mmu.c @@ -263,18 +263,16 @@ int etnaviv_iommu_map_gem(struct etnaviv_iommu *mmu, if (iova < 0x80000000 - sg_dma_len(sgt->sgl)) { mapping->iova = iova; list_add_tail(&mapping->mmu_node, &mmu->mappings); - mutex_unlock(&mmu->lock); - return 0; + ret = 0; + goto unlock; } } node = &mapping->vram_node; ret = etnaviv_iommu_find_iova(mmu, node, etnaviv_obj->base.size); - if (ret < 0) { - mutex_unlock(&mmu->lock); - return ret; - } + if (ret < 0) + goto unlock; mmu->last_iova = node->start + etnaviv_obj->base.size; mapping->iova = node->start; @@ -283,12 +281,12 @@ int etnaviv_iommu_map_gem(struct etnaviv_iommu *mmu, if (ret < 0) { drm_mm_remove_node(node); - mutex_unlock(&mmu->lock); - return ret; + goto unlock; } list_add_tail(&mapping->mmu_node, &mmu->mappings); mmu->need_flush = true; +unlock: mutex_unlock(&mmu->lock); return ret; |