From: Richard Henderson <richard.henderson@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Peter Maydell" <peter.maydell@linaro.org>,
qemu-devel@nongnu.org
Cc: Ben Dooks <ben.dooks@codethink.co.uk>,
qemu-riscv@nongnu.org, qemu-block@nongnu.org,
qemu-arm@nongnu.org, Guenter Roeck <linux@roeck-us.net>,
Bin Meng <bmeng.cn@gmail.com>,
Beniamino Galvani <b.galvani@gmail.com>,
Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
Subject: Re: [PATCH-for-10.1 v2 03/11] hw/sd/sdbus: Provide buffer size to sdbus_do_command()
Date: Tue, 5 Aug 2025 08:56:36 +1000 [thread overview]
Message-ID: <b7c6b929-ec99-4eb2-9f9b-c91632dd8ac3@linaro.org> (raw)
In-Reply-To: <20250804133406.17456-4-philmd@linaro.org>
On 8/4/25 23:33, Philippe Mathieu-Daudé wrote:
> We provide to sdbus_do_command() a pointer to a buffer to be
> filled with a varying number of bytes. By not providing the
> buffer size, the callee can not check the buffer is big enough.
> Pass the buffer size as argument to follow good practices.
>
> sdbus_do_command() doesn't return any error, only the size filled
> in the buffer. Convert the returned type to unsigned and remove
> the few unreachable lines in callers.
>
> This allow to check for possible overflow in sd_do_command().
>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> include/hw/sd/sd.h | 23 +++++++++++++++++++++--
> hw/sd/allwinner-sdhost.c | 7 ++-----
> hw/sd/bcm2835_sdhost.c | 7 ++-----
> hw/sd/core.c | 5 +++--
> hw/sd/omap_mmc.c | 5 +++--
> hw/sd/pl181.c | 6 ++----
> hw/sd/sd.c | 6 ++++--
> hw/sd/sdhci.c | 6 +++---
> hw/sd/ssi-sd.c | 12 +++++++-----
> 9 files changed, 47 insertions(+), 30 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
next prev parent reply other threads:[~2025-08-04 22:57 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-04 13:33 [PATCH-for-10.1 v2 00/11] hw/sd: Fix SD cards in SPI mode Philippe Mathieu-Daudé
2025-08-04 13:33 ` [PATCH-for-10.1 v2 01/11] hw/sd/sdcard: Do not ignore errors in sd_cmd_to_sendingdata() Philippe Mathieu-Daudé
2025-08-04 13:33 ` [PATCH-for-10.1 v2 02/11] hw/sd/sdcard: Factor sd_response_size() out Philippe Mathieu-Daudé
2025-08-04 22:55 ` Richard Henderson
2025-08-04 13:33 ` [PATCH-for-10.1 v2 03/11] hw/sd/sdbus: Provide buffer size to sdbus_do_command() Philippe Mathieu-Daudé
2025-08-04 22:56 ` Richard Henderson [this message]
2025-08-04 13:33 ` [PATCH-for-10.1 v2 04/11] hw/sd/sdcard: Fill SPI response bits in card code Philippe Mathieu-Daudé
2025-08-04 13:33 ` [PATCH-for-10.1 v2 05/11] hw/sd/sdcard: Implement SPI R2 return value Philippe Mathieu-Daudé
2025-08-04 13:34 ` [PATCH-for-10.1 v2 06/11] hw/sd/sdcard: Use complete SEND_OP_COND implementation in SPI mode Philippe Mathieu-Daudé
2025-08-04 13:34 ` [PATCH-for-10.1 v2 07/11] hw/sd/sdcard: Allow using SWITCH_FUNCTION in more SPI states Philippe Mathieu-Daudé
2025-08-04 13:34 ` [PATCH-for-10.1 v2 08/11] hw/sd/sdcard: Factor spi_cmd_SEND_CxD() out Philippe Mathieu-Daudé
2025-08-04 13:34 ` [PATCH-for-10.1 v2 09/11] hw/sd/sdcard: Disable checking STBY mode in SPI SEND_CSD/CID Philippe Mathieu-Daudé
2025-08-04 13:34 ` [PATCH-for-10.1 v2 10/11] hw/sd/sdcard: Remove SDState::mode field Philippe Mathieu-Daudé
2025-08-04 13:34 ` [PATCH-for-10.1 v2 11/11] tests/functional: Test SD cards in SPI mode (using sifive_u machine) Philippe Mathieu-Daudé
2025-08-04 23:03 ` [PATCH-for-10.1 v2 00/11] hw/sd: Fix SD cards in SPI mode Richard Henderson
2025-08-04 23:09 ` Philippe Mathieu-Daudé
2025-08-05 14:29 ` Philippe Mathieu-Daudé
2025-08-06 6:39 ` Michael Tokarev
2025-08-06 7:22 ` Philippe Mathieu-Daudé
2025-08-07 16:06 ` Guenter Roeck
2025-08-08 13:34 ` Philippe Mathieu-Daudé
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=b7c6b929-ec99-4eb2-9f9b-c91632dd8ac3@linaro.org \
--to=richard.henderson@linaro.org \
--cc=b.galvani@gmail.com \
--cc=ben.dooks@codethink.co.uk \
--cc=bmeng.cn@gmail.com \
--cc=linux@roeck-us.net \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=strahinja.p.jankovic@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).