drivers/staging/rtl8723bs/hal/sdio_ops.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
The sdio_read32() calls sd_read(), but does not handle the error if
sd_read() fails. This could lead to subsequent operations processing
invalid data. A proper implementation can be found in sdio_readN().
Add error handling to the sd_read(), ensuring that the memcpy() is
only performed when the read operation is successful.
Fixes: 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver")
Cc: stable@vger.kernel.org # v4.12+
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/staging/rtl8723bs/hal/sdio_ops.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c
index 21e9f1858745..b21fd087c9a0 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
@@ -185,9 +185,11 @@ static u32 sdio_read32(struct intf_hdl *intfhdl, u32 addr)
return SDIO_ERR_VAL32;
ftaddr &= ~(u16)0x3;
- sd_read(intfhdl, ftaddr, 8, tmpbuf);
- memcpy(&le_tmp, tmpbuf + shift, 4);
- val = le32_to_cpu(le_tmp);
+ val = sd_read(intfhdl, ftaddr, 8, tmpbuf);
+ if (!val) {
+ memcpy(&le_tmp, tmpbuf + shift, 4);
+ val = le32_to_cpu(le_tmp);
+ }
kfree(tmpbuf);
}
--
2.42.0.windows.2
On Sat, Apr 05, 2025 at 10:07:02PM +0800, Wentao Liang wrote:
> The sdio_read32() calls sd_read(), but does not handle the error if
> sd_read() fails. This could lead to subsequent operations processing
> invalid data. A proper implementation can be found in sdio_readN().
>
> Add error handling to the sd_read(), ensuring that the memcpy() is
> only performed when the read operation is successful.
>
> Fixes: 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver")
> Cc: stable@vger.kernel.org # v4.12+
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
You need to add an explanation here what changed in v3.
https://staticthinking.wordpress.com/2022/07/27/how-to-send-a-v2-patch/
> drivers/staging/rtl8723bs/hal/sdio_ops.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c
> index 21e9f1858745..b21fd087c9a0 100644
> --- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
> +++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
> @@ -185,9 +185,11 @@ static u32 sdio_read32(struct intf_hdl *intfhdl, u32 addr)
> return SDIO_ERR_VAL32;
>
> ftaddr &= ~(u16)0x3;
> - sd_read(intfhdl, ftaddr, 8, tmpbuf);
> - memcpy(&le_tmp, tmpbuf + shift, 4);
> - val = le32_to_cpu(le_tmp);
> + val = sd_read(intfhdl, ftaddr, 8, tmpbuf);
> + if (!val) {
The sdio_read32() function now returns negative error codes. Probably
a bad idea.
regards,
dan carpenter
> + memcpy(&le_tmp, tmpbuf + shift, 4);
> + val = le32_to_cpu(le_tmp);
> + }
>
> kfree(tmpbuf);
> }
> --
> 2.42.0.windows.2
>
© 2016 - 2026 Red Hat, Inc.