Skip to contentSkip to conversation

coresight: etb10: Fix check for bogus buffer depth

PATCH New Mark Brown 2 participants 2 messages Apr 8, 2015 – Apr 9, 2015

Subsystems (2)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/1 coresight: etb10: Fix check for bogus buffer depth

We attempt to sanity check the buffer depth reported by the hardware by making sure it is not less than zero however this check will never be true since the buffer depth is stored in an unsigned integer. Instead change the check to look for the top bit being set which was the intention.

---

This depends on the patch I sent earlier today for context though there's no direct dependency (and this check isn't sufficient to catch the fault I'm seeing).

 drivers/hwtracing/coresight/coresight-etb10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwtracing/coresight/coresight-etb10.c +1 -1
index 46eb9f88a29f..2a77d83130e6 100644
@@ -457,7 +457,7 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id)
 	drvdata->buffer_depth = etb_get_buffer_depth(drvdata);
 	clk_disable_unprepare(drvdata->clk);
 
-	if (drvdata->buffer_depth < 0)
+	if (drvdata->buffer_depth & 0x80000000)
 		return -EINVAL;
 
 	drvdata->buf = devm_kzalloc(dev,
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/1 coresight: etb10: Fix check for bogus buffer depth

Quoted 29 lines · Mark Brown

We attempt to sanity check the buffer depth reported by the hardware by making sure it is not less than zero however this check will never be true since the buffer depth is stored in an unsigned integer. Instead change the check to look for the top bit being set which was the intention.

---

This depends on the patch I sent earlier today for context though there's no direct dependency (and this check isn't sufficient to catch the fault I'm seeing).

 drivers/hwtracing/coresight/coresight-etb10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwtracing/coresight/coresight-etb10.c +1 -2
index 46eb9f88a29f..2a77d83130e6 100644
@@ -457,7 +457,7 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id)
        drvdata->buffer_depth = etb_get_buffer_depth(drvdata);
        clk_disable_unprepare(drvdata->clk);
 
-       if (drvdata->buffer_depth < 0)
+       if (drvdata->buffer_depth & 0x80000000)
                return -EINVAL;
 
        drvdata->buf = devm_kzalloc(dev,
--
Quoted 2 lines

2.1.4

Good catch - applied.

Thanks,
Mathieu