All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] coresight: next 4.0-rc7
@ 2015-04-10 15:25 ` Mathieu Poirier
  0 siblings, 0 replies; 6+ messages in thread
From: Mathieu Poirier @ 2015-04-10 15:25 UTC (permalink / raw)
  To: gregkh; +Cc: linux-arm-kernel, linux-kernel, zhang.chunyan, kaixu.xia

Good morning,

I'd appreciate if this could go in the 4.1 merge window with the other
coresight fix.  If this is too close for comfort then we'll simply get
the next one.

Thanks,
Mathieu

Mark Brown (2):
  coresight: etb10: Print size of buffer we fail to allocate
  coresight: etb10: Fix check for bogus buffer depth

 drivers/hwtracing/coresight/coresight-etb10.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

-- 
1.9.1


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

* [PATCH 0/2] coresight: next 4.0-rc7
@ 2015-04-10 15:25 ` Mathieu Poirier
  0 siblings, 0 replies; 6+ messages in thread
From: Mathieu Poirier @ 2015-04-10 15:25 UTC (permalink / raw)
  To: linux-arm-kernel

Good morning,

I'd appreciate if this could go in the 4.1 merge window with the other
coresight fix.  If this is too close for comfort then we'll simply get
the next one.

Thanks,
Mathieu

Mark Brown (2):
  coresight: etb10: Print size of buffer we fail to allocate
  coresight: etb10: Fix check for bogus buffer depth

 drivers/hwtracing/coresight/coresight-etb10.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

-- 
1.9.1

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

* [PATCH 1/2] coresight: etb10: Print size of buffer we fail to allocate
  2015-04-10 15:25 ` Mathieu Poirier
@ 2015-04-10 15:25   ` Mathieu Poirier
  -1 siblings, 0 replies; 6+ messages in thread
From: Mathieu Poirier @ 2015-04-10 15:25 UTC (permalink / raw)
  To: gregkh; +Cc: linux-arm-kernel, linux-kernel, zhang.chunyan, kaixu.xia

From: Mark Brown <broonie@kernel.org>

When we initialise the ETB driver we attempt to allocate a buffer suitable
for storing the data buffered in the hardware based on sizing information
reported by the hardware. Unfortunately if the hardware is not properly
configured (for example if power domains are not set up correctly) then we
may read back a nonsensically large value and therefore the allocation will
be too big to succeed. Print an error message showing the amount of memory
we tried to allocate if the buffer allocation fails to help users diagnose
such problems.

Normally it is bad practice to print an error message on memory allocation
failures since there are verbose core messages reported for this but in
this case where the allocation size might be incorrect it is a useful hint.

Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 drivers/hwtracing/coresight/coresight-etb10.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c
index 40049869aecd..46eb9f88a29f 100644
--- a/drivers/hwtracing/coresight/coresight-etb10.c
+++ b/drivers/hwtracing/coresight/coresight-etb10.c
@@ -462,8 +462,11 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id)
 
 	drvdata->buf = devm_kzalloc(dev,
 				    drvdata->buffer_depth * 4, GFP_KERNEL);
-	if (!drvdata->buf)
+	if (!drvdata->buf) {
+		dev_err(dev, "Failed to allocate %u bytes for buffer data\n",
+			drvdata->buffer_depth * 4);
 		return -ENOMEM;
+	}
 
 	desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL);
 	if (!desc)
-- 
1.9.1


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

* [PATCH 1/2] coresight: etb10: Print size of buffer we fail to allocate
@ 2015-04-10 15:25   ` Mathieu Poirier
  0 siblings, 0 replies; 6+ messages in thread
From: Mathieu Poirier @ 2015-04-10 15:25 UTC (permalink / raw)
  To: linux-arm-kernel

From: Mark Brown <broonie@kernel.org>

When we initialise the ETB driver we attempt to allocate a buffer suitable
for storing the data buffered in the hardware based on sizing information
reported by the hardware. Unfortunately if the hardware is not properly
configured (for example if power domains are not set up correctly) then we
may read back a nonsensically large value and therefore the allocation will
be too big to succeed. Print an error message showing the amount of memory
we tried to allocate if the buffer allocation fails to help users diagnose
such problems.

Normally it is bad practice to print an error message on memory allocation
failures since there are verbose core messages reported for this but in
this case where the allocation size might be incorrect it is a useful hint.

Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 drivers/hwtracing/coresight/coresight-etb10.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c
index 40049869aecd..46eb9f88a29f 100644
--- a/drivers/hwtracing/coresight/coresight-etb10.c
+++ b/drivers/hwtracing/coresight/coresight-etb10.c
@@ -462,8 +462,11 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id)
 
 	drvdata->buf = devm_kzalloc(dev,
 				    drvdata->buffer_depth * 4, GFP_KERNEL);
-	if (!drvdata->buf)
+	if (!drvdata->buf) {
+		dev_err(dev, "Failed to allocate %u bytes for buffer data\n",
+			drvdata->buffer_depth * 4);
 		return -ENOMEM;
+	}
 
 	desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL);
 	if (!desc)
-- 
1.9.1

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

* [PATCH 2/2] coresight: etb10: Fix check for bogus buffer depth
  2015-04-10 15:25 ` Mathieu Poirier
@ 2015-04-10 15:25   ` Mathieu Poirier
  -1 siblings, 0 replies; 6+ messages in thread
From: Mathieu Poirier @ 2015-04-10 15:25 UTC (permalink / raw)
  To: gregkh; +Cc: linux-arm-kernel, linux-kernel, zhang.chunyan, kaixu.xia

From: Mark Brown <broonie@kernel.org>

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.

Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 drivers/hwtracing/coresight/coresight-etb10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c
index 46eb9f88a29f..2a77d83130e6 100644
--- a/drivers/hwtracing/coresight/coresight-etb10.c
+++ b/drivers/hwtracing/coresight/coresight-etb10.c
@@ -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,
-- 
1.9.1


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

* [PATCH 2/2] coresight: etb10: Fix check for bogus buffer depth
@ 2015-04-10 15:25   ` Mathieu Poirier
  0 siblings, 0 replies; 6+ messages in thread
From: Mathieu Poirier @ 2015-04-10 15:25 UTC (permalink / raw)
  To: linux-arm-kernel

From: Mark Brown <broonie@kernel.org>

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.

Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 drivers/hwtracing/coresight/coresight-etb10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c
index 46eb9f88a29f..2a77d83130e6 100644
--- a/drivers/hwtracing/coresight/coresight-etb10.c
+++ b/drivers/hwtracing/coresight/coresight-etb10.c
@@ -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,
-- 
1.9.1

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

end of thread, other threads:[~2015-04-10 15:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-10 15:25 [PATCH 0/2] coresight: next 4.0-rc7 Mathieu Poirier
2015-04-10 15:25 ` Mathieu Poirier
2015-04-10 15:25 ` [PATCH 1/2] coresight: etb10: Print size of buffer we fail to allocate Mathieu Poirier
2015-04-10 15:25   ` Mathieu Poirier
2015-04-10 15:25 ` [PATCH 2/2] coresight: etb10: Fix check for bogus buffer depth Mathieu Poirier
2015-04-10 15:25   ` Mathieu Poirier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.