lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Wed,  6 Sep 2017 11:20:37 +0530
From:   Pushkar Jambhlekar <pushkar.iit@...il.com>
To:     Hiroshi Doyu <hdoyu@...dia.com>, Joerg Roedel <joro@...tes.org>,
        Thierry Reding <thierry.reding@...il.com>,
        Jonathan Hunter <jonathanh@...dia.com>
Cc:     iommu@...ts.linux-foundation.org, linux-tegra@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        Pushkar Jambhlekar <pushkar.iit@...il.com>
Subject: [PATCH] drivers/iommu/tegra: Optimize mutex_unlock function call

Code can be optimized more by making single exit point of function and calling mutex_unlock at the end

Signed-off-by: Pushkar Jambhlekar <pushkar.iit@...il.com>
---
 drivers/iommu/tegra-smmu.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
index 3b6449e..da38833 100644
--- a/drivers/iommu/tegra-smmu.c
+++ b/drivers/iommu/tegra-smmu.c
@@ -232,20 +232,22 @@ static inline void smmu_flush(struct tegra_smmu *smmu)
 static int tegra_smmu_alloc_asid(struct tegra_smmu *smmu, unsigned int *idp)
 {
 	unsigned long id;
+	int ret = 0;
 
 	mutex_lock(&smmu->lock);
 
 	id = find_first_zero_bit(smmu->asids, smmu->soc->num_asids);
 	if (id >= smmu->soc->num_asids) {
-		mutex_unlock(&smmu->lock);
-		return -ENOSPC;
+		ret = -ENOSPC;
+		goto Exit;
 	}
 
 	set_bit(id, smmu->asids);
 	*idp = id;
 
+Exit:
 	mutex_unlock(&smmu->lock);
-	return 0;
+	return ret;
 }
 
 static void tegra_smmu_free_asid(struct tegra_smmu *smmu, unsigned int id)
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ