From: Dan Carpenter <dan.carpenter@linaro.org>
To: Minu Jin <s9430939@naver.com>
Cc: gregkh@linuxfoundation.org, andriy.shevchenko@linux.intel.com,
abrahamadekunle50@gmail.com, zxcv2569763104@gmail.com,
milospuric856@gmail.com, karanja99erick@gmail.com,
weibu@redadmin.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 1/3] staging: rtl8723bs: change return type of _rtw_pktfile_read to int
Date: Thu, 22 Jan 2026 08:35:09 +0300 [thread overview]
Message-ID: <aXG3DSMRf1Ojn436@stanley.mountain> (raw)
In-Reply-To: <20260122041450.2325560-2-s9430939@naver.com>
On Thu, Jan 22, 2026 at 01:14:48PM +0900, Minu Jin wrote:
> The current return type of _rtw_pktfile_read() is uint,
> which makes it impossible to propagate negative error codes
> from internal calls (skb_copy_bits()).
>
> In preparation for returning proper error codes
> (eg, skb_copy_bits return -EFAULT when error occurs)
> when data is insufficient or copying fails, change the function's
> return type to int.
>
> Additionally, update the type of the 'rlen' parameter, 'len' variable
> from 'uint' to 'unsigned int' to comply with the kernel coding style
> as suggested by Andy Shevchenko.
>
> Signed-off-by: Minu Jin <s9430939@naver.com>
> ---
> drivers/staging/rtl8723bs/include/xmit_osdep.h | 2 +-
> drivers/staging/rtl8723bs/os_dep/xmit_linux.c | 14 +++++++++-----
> 2 files changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/staging/rtl8723bs/include/xmit_osdep.h b/drivers/staging/rtl8723bs/include/xmit_osdep.h
> index 8704dced593a..880344bffe2f 100644
> --- a/drivers/staging/rtl8723bs/include/xmit_osdep.h
> +++ b/drivers/staging/rtl8723bs/include/xmit_osdep.h
> @@ -35,7 +35,7 @@ void rtw_os_xmit_resource_free(struct adapter *padapter, struct xmit_buf *pxmitb
>
> extern uint rtw_remainder_len(struct pkt_file *pfile);
> extern void _rtw_open_pktfile(struct sk_buff *pkt, struct pkt_file *pfile);
> -extern uint _rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen);
> +int _rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, unsigned int rlen);
> extern signed int rtw_endofpktfile(struct pkt_file *pfile);
>
> extern void rtw_os_pkt_complete(struct adapter *padapter, struct sk_buff *pkt);
> diff --git a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
> index 944b9c724b32..ea54a573e025 100644
> --- a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
> +++ b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
> @@ -21,15 +21,19 @@ void _rtw_open_pktfile(struct sk_buff *pktptr, struct pkt_file *pfile)
> pfile->cur_buffer = pfile->buf_start;
> }
>
> -uint _rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen)
> +int _rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, unsigned int rlen)
> {
> - uint len = 0;
> + unsigned int len;
> + int ret;
>
> len = rtw_remainder_len(pfile);
> - len = (rlen > len) ? len : rlen;
> + len = (rlen > len) ? len : rlen;
How did you generate this diff? The before and after lines are
exactly the same.
>
> - if (rmem)
> - skb_copy_bits(pfile->pkt, pfile->buf_len - pfile->pkt_len, rmem, len);
> + if (rmem) {
> + ret = skb_copy_bits(pfile->pkt, pfile->buf_len - pfile->pkt_len, rmem, len);
> + if (ret < 0)
> + return ret;
No, you can't do this or it will cause a bug in rtw_xmitframe_coalesce().
So that also means don't change the return type from uint to int in this
patch either.
Normally, we would do the bugfix first and then the cleanup in the
follow on patches. That way we could backport the fix and leave the
cleanup. It doesn't matter in a practical sense in this code but
that's the better way.
regards,
dan carpenter
> + }
>
> pfile->cur_addr += len;
> pfile->pkt_len -= len;
> --
> 2.43.0
next prev parent reply other threads:[~2026-01-22 5:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-22 4:14 [PATCH v5 0/3] staging: rtl8723bs: improve error handling in _rtw_pktfile_read Minu Jin
2026-01-22 4:14 ` [PATCH v5 1/3] staging: rtl8723bs: change return type of _rtw_pktfile_read to int Minu Jin
2026-01-22 5:35 ` Dan Carpenter [this message]
2026-01-22 4:14 ` [PATCH v5 2/3] staging: rtl8723bs: update callers to handle negative error codes Minu Jin
2026-01-22 4:14 ` [PATCH v5 3/3] staging: rtl8723bs: prevent partial reads in _rtw_pktfile_read Minu Jin
2026-01-22 5:57 ` Dan Carpenter
-- strict thread matches above, loose matches on Subject: below --
2026-01-22 13:23 [PATCH v5 1/3] staging: rtl8723bs: change return type of _rtw_pktfile_read to int Minu Jin
2026-01-22 15:31 ` Dan Carpenter
2026-01-22 14:23 Minu Jin
2026-01-22 14:35 ` Greg KH
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=aXG3DSMRf1Ojn436@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=abrahamadekunle50@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=karanja99erick@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=milospuric856@gmail.com \
--cc=s9430939@naver.com \
--cc=weibu@redadmin.org \
--cc=zxcv2569763104@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