linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] perf: arm-cmn: fix less than zero check on unsigned dtc->irq
@ 2020-10-02 15:48 Colin King
  2020-10-05  8:26 ` Will Deacon
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2020-10-02 15:48 UTC (permalink / raw)
  To: Will Deacon, Mark Rutland, Robin Murphy, linux-arm-kernel
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently the failure check on dtc->irq is always false because
dtc->irq is an unsigned int. Fix this by using a temporary signed
int for the less than zero error check.

Addresses-Coverity: ("Unsigned compared against 0")
Fixes: 0ba64770a2f2 ("perf: Add Arm CMN-600 PMU driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 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 a76ff594f3ca..21819af163f3 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 irq;
 
 	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;
+	irq = platform_get_irq(to_platform_device(cmn->dev), idx);
+	if (irq < 0)
+		return irq;
+	dtc->irq = irq;
 
 	writel_relaxed(0, dtc->base + CMN_DT_PMCR);
 	writel_relaxed(0x1ff, dtc->base + CMN_DT_PMOVSR_CLR);
-- 
2.27.0


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

* Re: [PATCH][next] perf: arm-cmn: fix less than zero check on unsigned dtc->irq
  2020-10-02 15:48 [PATCH][next] perf: arm-cmn: fix less than zero check on unsigned dtc->irq Colin King
@ 2020-10-05  8:26 ` Will Deacon
  0 siblings, 0 replies; 2+ messages in thread
From: Will Deacon @ 2020-10-05  8:26 UTC (permalink / raw)
  To: Colin King
  Cc: Mark Rutland, Robin Murphy, linux-arm-kernel, kernel-janitors,
	linux-kernel

On Fri, Oct 02, 2020 at 04:48:00PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently the failure check on dtc->irq is always false because
> dtc->irq is an unsigned int. Fix this by using a temporary signed
> int for the less than zero error check.
> 
> Addresses-Coverity: ("Unsigned compared against 0")
> Fixes: 0ba64770a2f2 ("perf: Add Arm CMN-600 PMU driver")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/perf/arm-cmn.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)

Cheers, but Gustavo beat you to it and I had a crack at a different fix
which should now be in -next:

https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/commit/?h=for-next/core&id=d9ef632fab9ba81b708763bcbcfdbea9a55c95d2

Will

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

end of thread, other threads:[~2020-10-05  8:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-02 15:48 [PATCH][next] perf: arm-cmn: fix less than zero check on unsigned dtc->irq Colin King
2020-10-05  8:26 ` Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).