From: sashiko-bot@kernel.org
To: "Rosen Penev" <rosenp@gmail.com>
Cc: dlemoal@kernel.org, linux-ide@vger.kernel.org, cassel@kernel.org
Subject: Re: [PATCH] ata: pata_ep93xx: fix incorrect return value in data_xfer
Date: Mon, 01 Jun 2026 19:32:07 +0000 [thread overview]
Message-ID: <20260601193208.0CA1B1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260601192109.21262-1-rosenp@gmail.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [High] The patch returns `buflen` instead of the actual number of bytes consumed from the device hardware, causing ATAPI PIO transfers with odd byte counts to fail.
- [Low] The `words++` statement is left behind as dead code.
Pre-existing issues:
- [High] The fallback path for odd-length trailing bytes incorrectly assigns 16-bit values to an 8-bit pointer, breaking big-endian systems due to endianness swapping and data truncation.
--
commit a4f8c7ea905bbd7b345d74a2225d1a93448d03c1
Author: Rosen Penev <rosenp@gmail.com>
ata: pata_ep93xx: fix incorrect return value in data_xfer
This patch modifies ep93xx_pata_data_xfer() to return buflen instead of the
shifted words counter. It aims to fix an underflow from 0 to UINT_MAX on exit
when managing scatter-gather progress for ATAPI PIO transfers.
> diff --git a/drivers/ata/pata_ep93xx.c b/drivers/ata/pata_ep93xx.c
> --- a/drivers/ata/pata_ep93xx.c
> +++ b/drivers/ata/pata_ep93xx.c
[ ... ]
> /* Transfer trailing 1 byte, if any. */
> if (unlikely(buflen & 0x01)) {
> unsigned char pad[2] = { };
>
> buf += buflen - 1;
>
> if (rw == READ) {
> *pad = cpu_to_le16(
> ep93xx_pata_read_data(
> drv_data, IDECTRL_ADDR_DATA));
[Severity: High]
This is a pre-existing issue, but does assigning the 16-bit result of
cpu_to_le16() to the 8-bit *pad cause data truncation and endianness bugs
on big-endian systems?
It looks like the fallback path for odd-length trailing bytes might need a
cast to extract the correct byte.
> *buf = pad[0];
> } else {
> pad[0] = *buf;
> ep93xx_pata_write_data(drv_data, le16_to_cpu(*pad),
> IDECTRL_ADDR_DATA);
> }
> words++;
[Severity: Low]
This isn't a regression, but since the return statement below no longer uses
the words variable, does this words++ statement become dead code?
> }
>
> - return words << 1;
> + return buflen;
[Severity: High]
Does returning the unrounded buflen instead of the actual number of bytes
consumed from the hardware cause a regression where __atapi_pio_bytes()
under-decrements its remaining byte count?
If buflen is an odd number, returning buflen instead of the rounded hardware
byte count could trigger an extra unintended read cycle and subsequent HSM
errors for ATAPI PIO transfers. Should this return the consumed bytes rounded
to the hardware transfer size instead?
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260601192109.21262-1-rosenp@gmail.com?part=1
prev parent reply other threads:[~2026-06-01 19:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-01 19:21 [PATCH] ata: pata_ep93xx: fix incorrect return value in data_xfer Rosen Penev
2026-06-01 19:32 ` sashiko-bot [this message]
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=20260601193208.0CA1B1F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=rosenp@gmail.com \
--cc=sashiko-reviews@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox