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 3/3] staging: rtl8723bs: prevent partial reads in _rtw_pktfile_read
Date: Thu, 22 Jan 2026 08:57:53 +0300 [thread overview]
Message-ID: <aXG8YWkFlfiOSSHD@stanley.mountain> (raw)
In-Reply-To: <20260122041450.2325560-4-s9430939@naver.com>
On Thu, Jan 22, 2026 at 01:14:50PM +0900, Minu Jin wrote:
> The current implementation of _rtw_pktfile_read() allows reading less
> data than requested if there isn't enough data remaining.
>
> This is problematic because callers usually request a fixed size (like
> a header size) and expect that full amount. Reading only part of the
> data means the caller gets incomplete information, which can lead to
> errors in packet processing.
>
> To fix this, update the function to:
> 1. Return -EINVAL if the remaining data is smaller than the requested
> length.
> 2. Check the return value of skb_copy_bits() and propagate errors.
> 3. Only update the internal pointers (cur_addr, pkt_len) if the read
> is fully successful.
>
> Callers have already been updated in previous patches to handle these
> negative error codes.
>
> Signed-off-by: Minu Jin <s9430939@naver.com>
> ---
> drivers/staging/rtl8723bs/os_dep/xmit_linux.c | 13 ++++++-------
> 1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
> index ea54a573e025..72cf8cd5f7c6 100644
> --- a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
> +++ b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
> @@ -23,21 +23,20 @@ void _rtw_open_pktfile(struct sk_buff *pktptr, struct pkt_file *pfile)
>
> int _rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, unsigned int rlen)
> {
> - unsigned int len;
> int ret;
>
> - len = rtw_remainder_len(pfile);
> - len = (rlen > len) ? len : rlen;
The rest of this looks okay. But just drop patch 1 since you
delete the len variable in the end anyway. Leave the type alone and
leave the whitespace alone. Your subjects are too vague.
patch 1: update _rtw_pktfile_read() to return error codes
patch 2: clean up _rtw_pktfile_read()
regards,
dan carpenter
prev parent reply other threads:[~2026-01-22 5:57 UTC|newest]
Thread overview: 6+ 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
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 [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=aXG8YWkFlfiOSSHD@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 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.