Skip to contentSkip to conversation

perf: arm-cmn: Fix unsigned comparison to less than zero

PATCH In review Will Deacon 2 participants 3 messages Oct 1, 2020

Subsystems (2)
lore
Share & tools
lore

Will Deacon

author maintainer
#0 lore raw

PATCH 1/2 perf: arm-cmn: Fix unsigned comparison to less than zero

Ensure that the 'irq' field of 'struct arm_cmn_dtc' is a signed int so that it can be compared '< 0'.

Addresses-Coverity-ID: 1497488 ("Unsigned compared against 0")

Fixes 0ba64770a2f2 ("perf: Add Arm CMN-600 PMU driver")
---
 drivers/perf/arm-cmn.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/perf/arm-cmn.c +1 -1
index e824b5b83ea2..cd4da4c5dac0 100644
@@ -217,7 +217,7 @@ struct arm_cmn_node {
 
 struct arm_cmn_dtc {
 	void __iomem *base;
-	unsigned int irq;
+	int irq;
 	int irq_friend;
 	bool cc_active;
 
Signature · 7 lines
2.28.0.709.gb0816b6eb0-goog


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author maintainer
#1 lore raw

PATCH 2/2 perf: arm-cmn: Fix conversion specifiers for node type

The node type field is an enum type, so print it as a 32-bit quantity rather than as an unsigned short.

---
 drivers/perf/arm-cmn.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/perf/arm-cmn.c +2 -2
index cd4da4c5dac0..a76ff594f3ca 100644
@@ -1324,7 +1324,7 @@ static void arm_cmn_init_node_info(struct arm_cmn *cmn, u32 offset, struct arm_c
 	else
 		level = 2;
 
-	dev_dbg(cmn->dev, "node%*c%#06hx%*ctype:%-#6hx id:%-4hd off:%#x\n",
+	dev_dbg(cmn->dev, "node%*c%#06hx%*ctype:%-#6x id:%-4hd off:%#x\n",
 			(level * 2) + 1, ' ', node->id, 5 - (level * 2), ' ',
 			node->type, node->logid, offset);
 }
@@ -1430,7 +1430,7 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)
 				break;
 			/* Something has gone horribly wrong */
 			default:
-				dev_err(cmn->dev, "invalid device node type: 0x%hx\n", dn->type);
+				dev_err(cmn->dev, "invalid device node type: 0x%x\n", dn->type);
 				return -ENODEV;
 			}
 		}
Signature · 7 lines
2.28.0.709.gb0816b6eb0-goog


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Reviewed-by on v1 1/2
#2 lore raw
In reply to Will Deacon
Quoted 8 lines · Will Deacon

Ensure that the 'irq' field of 'struct arm_cmn_dtc' is a signed int so that it can be compared '< 0'.

Addresses-Coverity-ID: 1497488 ("Unsigned compared against 0")

Fixes 0ba64770a2f2 ("perf: Add Arm CMN-600 PMU driver")

Thanks
--
Gustavo

Quoted 20 lines
---
 drivers/perf/arm-cmn.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/perf/arm-cmn.c +1 -1
index e824b5b83ea2..cd4da4c5dac0 100644
@@ -217,7 +217,7 @@ struct arm_cmn_node {
 
 struct arm_cmn_dtc {
 	void __iomem *base;
-	unsigned int irq;
+	int irq;
 	int irq_friend;
 	bool cc_active;
 
Signature · 1 line
2.28.0.709.gb0816b6eb0-goog

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel