All of lore.kernel.org
 help / color / mirror / Atom feed
From: sergei.shtylyov@cogentembedded.com (Sergei Shtylyov)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] dma: at_hdmac: fix invalid remaining bytes detection
Date: Fri, 01 Aug 2014 18:08:55 +0400	[thread overview]
Message-ID: <53DB9F77.6000102@cogentembedded.com> (raw)
In-Reply-To: <1406887406-10567-1-git-send-email-alexandre.belloni@free-electrons.com>

Hello.

On 08/01/2014 02:03 PM, Alexandre Belloni wrote:

> Found using smatch:
> drivers/dma/at_hdmac.c:299 atc_get_bytes_left() warn: unsigned
> 'atchan->remain_desc' is never less than zero.

> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
>   drivers/dma/at_hdmac.c | 12 +++++++-----
>   1 file changed, 7 insertions(+), 5 deletions(-)

> diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
> index c13a3bb0f594..9ec84ee2fa25 100644
> --- a/drivers/dma/at_hdmac.c
> +++ b/drivers/dma/at_hdmac.c
> @@ -294,14 +294,16 @@ static int atc_get_bytes_left(struct dma_chan *chan)
>   			ret = -EINVAL;
>   			goto out;
>   		}
> -		atchan->remain_desc -= (desc_cur->lli.ctrla & ATC_BTSIZE_MAX)
> -						<< (desc_first->tx_width);
> -		if (atchan->remain_desc < 0) {
> +
> +		count = (desc_cur->lli.ctrla & ATC_BTSIZE_MAX)
> +			<< (desc_first->tx_width);

    Parens not needed here.

[...]

WBR, Sergei

WARNING: multiple messages have this Message-ID (diff)
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Alexandre Belloni <alexandre.belloni@free-electrons.com>,
	Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: dmaengine@vger.kernel.org,
	Ludovic Desroches <ludovic.desroches@atmel.com>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] dma: at_hdmac: fix invalid remaining bytes detection
Date: Fri, 01 Aug 2014 18:08:55 +0400	[thread overview]
Message-ID: <53DB9F77.6000102@cogentembedded.com> (raw)
In-Reply-To: <1406887406-10567-1-git-send-email-alexandre.belloni@free-electrons.com>

Hello.

On 08/01/2014 02:03 PM, Alexandre Belloni wrote:

> Found using smatch:
> drivers/dma/at_hdmac.c:299 atc_get_bytes_left() warn: unsigned
> 'atchan->remain_desc' is never less than zero.

> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
>   drivers/dma/at_hdmac.c | 12 +++++++-----
>   1 file changed, 7 insertions(+), 5 deletions(-)

> diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
> index c13a3bb0f594..9ec84ee2fa25 100644
> --- a/drivers/dma/at_hdmac.c
> +++ b/drivers/dma/at_hdmac.c
> @@ -294,14 +294,16 @@ static int atc_get_bytes_left(struct dma_chan *chan)
>   			ret = -EINVAL;
>   			goto out;
>   		}
> -		atchan->remain_desc -= (desc_cur->lli.ctrla & ATC_BTSIZE_MAX)
> -						<< (desc_first->tx_width);
> -		if (atchan->remain_desc < 0) {
> +
> +		count = (desc_cur->lli.ctrla & ATC_BTSIZE_MAX)
> +			<< (desc_first->tx_width);

    Parens not needed here.

[...]

WBR, Sergei


  reply	other threads:[~2014-08-01 14:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-01 10:03 [PATCH] dma: at_hdmac: fix invalid remaining bytes detection Alexandre Belloni
2014-08-01 10:03 ` Alexandre Belloni
2014-08-01 14:08 ` Sergei Shtylyov [this message]
2014-08-01 14:08   ` Sergei Shtylyov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53DB9F77.6000102@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.