Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1479833 > unrolled thread

[PATCH] coresight: stm: return error code instead of zero in .packet() to avoid dead loop

Started byChunyan Zhang <zhang.chunyan@linaro.org>
First post2016-09-09 12:20 +0200
Last post2016-09-09 17:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] coresight: stm: return error code instead of zero in .packet() to avoid dead loop Chunyan Zhang <zhang.chunyan@linaro.org> - 2016-09-09 12:20 +0200
    Re: [PATCH] coresight: stm: return error code instead of zero in  .packet() to avoid dead loop Mathieu Poirier <mathieu.poirier@linaro.org> - 2016-09-09 17:40 +0200

#1479833 — [PATCH] coresight: stm: return error code instead of zero in .packet() to avoid dead loop

FromChunyan Zhang <zhang.chunyan@linaro.org>
Date2016-09-09 12:20 +0200
Subject[PATCH] coresight: stm: return error code instead of zero in .packet() to avoid dead loop
Message-ID<sfr4B-1xy-11@gated-at.bofh.it>
In STM framework driver, the trace data writing loop would keep running
until it received a negative return value or the whole trace packet has
been written to STM device.  So if the .packet() of STM device always
returns zero since the device is not enabled or the parameter isn't
supported, STM framework driver will stall into a dead loop.

Returning -EACCES (Permission denied) in .packet() if the device is
disabled makes more sense, and this is the same for returning -EINVAL
if the channel passed into is not supported.

Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>
---
 drivers/hwtracing/coresight/coresight-stm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c
index 73be58a..6291ce1 100644
--- a/drivers/hwtracing/coresight/coresight-stm.c
+++ b/drivers/hwtracing/coresight/coresight-stm.c
@@ -399,10 +399,10 @@ static ssize_t stm_generic_packet(struct stm_data *stm_data,
 						   struct stm_drvdata, stm);
 
 	if (!(drvdata && local_read(&drvdata->mode)))
-		return 0;
+		return -EACCES;
 
 	if (channel >= drvdata->numsp)
-		return 0;
+		return -EINVAL;
 
 	ch_addr = (unsigned long)stm_channel_addr(drvdata, channel);
 
-- 
2.7.4

[toc] | [next] | [standalone]


#1480153 — Re: [PATCH] coresight: stm: return error code instead of zero in .packet() to avoid dead loop

FromMathieu Poirier <mathieu.poirier@linaro.org>
Date2016-09-09 17:40 +0200
SubjectRe: [PATCH] coresight: stm: return error code instead of zero in .packet() to avoid dead loop
Message-ID<sfw4i-4M9-43@gated-at.bofh.it>
In reply to#1479833
On 9 September 2016 at 04:18, Chunyan Zhang <zhang.chunyan@linaro.org> wrote:
> In STM framework driver, the trace data writing loop would keep running
> until it received a negative return value or the whole trace packet has
> been written to STM device.  So if the .packet() of STM device always
> returns zero since the device is not enabled or the parameter isn't
> supported, STM framework driver will stall into a dead loop.
>
> Returning -EACCES (Permission denied) in .packet() if the device is
> disabled makes more sense, and this is the same for returning -EINVAL
> if the channel passed into is not supported.
>
> Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>
> ---
>  drivers/hwtracing/coresight/coresight-stm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c
> index 73be58a..6291ce1 100644
> --- a/drivers/hwtracing/coresight/coresight-stm.c
> +++ b/drivers/hwtracing/coresight/coresight-stm.c
> @@ -399,10 +399,10 @@ static ssize_t stm_generic_packet(struct stm_data *stm_data,
>                                                    struct stm_drvdata, stm);
>
>         if (!(drvdata && local_read(&drvdata->mode)))
> -               return 0;
> +               return -EACCES;
>
>         if (channel >= drvdata->numsp)
> -               return 0;
> +               return -EINVAL;
>
>         ch_addr = (unsigned long)stm_channel_addr(drvdata, channel);
>
> --
> 2.7.4
>

Applied, but I had to change the title to "coresight: stm: return
error code instead of zero in .packet()" as the previous one exceeded
80 characters.

Thanks,
Mathieu

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web