public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH][next] perf: arm-cmn: Fix unsigned comparison to less than zero
@ 2020-09-29 17:08 Gustavo A. R. Silva
  2020-09-29 17:17 ` Will Deacon
  0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2020-09-29 17:08 UTC (permalink / raw)
  To: Will Deacon, Mark Rutland, Robin Murphy
  Cc: Robin Murphy, linux-kernel, linux-arm-kernel, Gustavo A. R. Silva

Fix unsigned comparison to less than zero by assigning the returned
value of function platform_get_irq() to a new integer variable _ret_
and then make the comparison. In case the returned value is greater
than or equal to zero, assign it to dtc->irq.

Addresses-Coverity-ID: 1497488 ("Unsigned compared against 0")
Fixes: 0ba64770a2f2 ("perf: Add Arm CMN-600 PMU driver")
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
 drivers/perf/arm-cmn.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c
index e824b5b83ea2..383b67042677 100644
--- a/drivers/perf/arm-cmn.c
+++ b/drivers/perf/arm-cmn.c
@@ -1246,11 +1246,13 @@ static int arm_cmn_init_dtc(struct arm_cmn *cmn, struct arm_cmn_node *dn, int id
 {
 	struct arm_cmn_dtc *dtc = cmn->dtc + idx;
 	struct arm_cmn_node *xp;
+	int ret;
 
 	dtc->base = dn->pmu_base - CMN_PMU_OFFSET;
-	dtc->irq = platform_get_irq(to_platform_device(cmn->dev), idx);
-	if (dtc->irq < 0)
-		return dtc->irq;
+	ret = platform_get_irq(to_platform_device(cmn->dev), idx);
+	if (ret < 0)
+		return ret;
+	dtc->irq = ret;
 
 	writel_relaxed(0, dtc->base + CMN_DT_PMCR);
 	writel_relaxed(0x1ff, dtc->base + CMN_DT_PMOVSR_CLR);
-- 
2.27.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-29 17:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-29 17:08 [PATCH][next] perf: arm-cmn: Fix unsigned comparison to less than zero Gustavo A. R. Silva
2020-09-29 17:17 ` Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox