From: Greg KH <gregkh@linuxfoundation.org>
To: Kees Bakker <kees@ijzerbout.nl>
Cc: Dave Penkler <dpenkler@gmail.com>,
Linux Staging <linux-staging@lists.linux.dev>
Subject: Re: [PATCH v3] staging: gpib: Change return type of fluke_get_dma_residue
Date: Thu, 7 Nov 2024 09:25:45 +0100 [thread overview]
Message-ID: <2024110714-scanner-apple-0792@gregkh> (raw)
In-Reply-To: <20241104193347.A0B5A18DD37@bout3.ijzerbout.nl>
On Tue, Oct 15, 2024 at 10:33:30PM +0200, Kees Bakker wrote:
> The function fluke_get_dma_residue returns an error as a negative value.
> So the return type must not be unsigned.
>
> This was detected by Coverity, CID 1600782
>
> Signed-off-by: Kees Bakker <kees@ijzerbout.nl>
> ---
> v1 -> v2: change type of `residue` var; add note about Coverity CID in commit message
> v2 -> v3: add version in the subject (sorry Greg)
>
> drivers/staging/gpib/eastwood/fluke_gpib.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/gpib/eastwood/fluke_gpib.c b/drivers/staging/gpib/eastwood/fluke_gpib.c
> index f9f149db222d..3843e986f104 100644
> --- a/drivers/staging/gpib/eastwood/fluke_gpib.c
> +++ b/drivers/staging/gpib/eastwood/fluke_gpib.c
> @@ -536,7 +536,7 @@ static int fluke_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length
> return 0;
> }
>
> -static unsigned int fluke_get_dma_residue(struct dma_chan *chan, dma_cookie_t cookie)
> +static int fluke_get_dma_residue(struct dma_chan *chan, dma_cookie_t cookie)
> {
> struct dma_tx_state state;
> int result;
> @@ -549,7 +549,7 @@ static unsigned int fluke_get_dma_residue(struct dma_chan *chan, dma_cookie_t co
> dmaengine_tx_status(chan, cookie, &state);
> // hardware doesn't support resume, so dont call this
> // method unless the dma transfer is done.
> - return state.residue;
> + return (int)state.residue;
Shouldn't you be checking the result of dmaengine_tx_status instead?
residue is a u32 and is NOT an error here so I think the unsigned value
here is correct as that's not going to give you what you expect it to
give you.
thanks,
greg k-h
next prev parent reply other threads:[~2024-11-07 8:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-15 20:33 [PATCH v3] staging: gpib: Change return type of fluke_get_dma_residue Kees Bakker
2024-11-07 8:25 ` Greg KH [this message]
2024-11-08 19:37 ` Kees Bakker
2024-11-11 10:59 ` Dan Carpenter
2024-11-11 11:06 ` Dan Carpenter
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=2024110714-scanner-apple-0792@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=dpenkler@gmail.com \
--cc=kees@ijzerbout.nl \
--cc=linux-staging@lists.linux.dev \
/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.