Netdev List
 help / color / mirror / Atom feed
From: Potnuri Bharat Teja <bharat@chelsio.com>
To: Dmitry Antipov <dmantipov@yandex.ru>
Cc: Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org
Subject: Re: [PATCH] cxgb4: use kstrtou16_from_user() in tp_la_write()
Date: Tue, 1 Dec 2026 18:22:45 +0530	[thread overview]
Message-ID: <aw7DHYjaU3ntb8lU@chelsio.com> (raw)
In-Reply-To: <20261120104907.831328-1-dmantipov@yandex.ru>

On Friday, November 11/20/26, 2026 at 13:49:07 +0300, Dmitry Antipov wrote:
> Simplify tp_la_write() by using kstrtou16_from_user().
> 
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
> ---
Hi Dmitry,

This looks like a resend of your 14 Aug posting, which Jakub marked as changes requested. 
The code is fine according to me, but the commit message still doesn't cover what that review 
asked for:

- kstrtou16_from_user() reads at most 18 bytes (the old code read 31), so longer input is silently truncated
- values above 0xffff now fail with -ERANGE instead of -EINVAL

Please send it as [PATCH net-next v2] with both points in the commit message and a changelog that links the v1 thread.

Thanks,
Bharat
>  drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
> index f521737d1275..ae9ab0d51e27 100644
> --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
> +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
> @@ -664,20 +664,13 @@ static ssize_t tp_la_write(struct file *file, const char __user *buf,
>  			   size_t count, loff_t *pos)
>  {
>  	int err;
> -	char s[32];
> -	unsigned long val;
> -	size_t size = min(sizeof(s) - 1, count);
> +	u16 val;
>  	struct adapter *adap = file_inode(file)->i_private;
>  
> -	if (copy_from_user(s, buf, size))
> -		return -EFAULT;
> -	s[size] = '\0';
> -	err = kstrtoul(s, 0, &val);
> +	err = kstrtou16_from_user(buf, count, 0, &val);
>  	if (err)
>  		return err;
> -	if (val > 0xffff)
> -		return -EINVAL;
> -	adap->params.tp.la_mask = val << 16;
> +	adap->params.tp.la_mask = (u32)val << 16;
>  	t4_set_reg_field(adap, TP_DBG_LA_CONFIG_A, 0xffff0000U,
>  			 adap->params.tp.la_mask);
>  	return count;
> -- 
> 2.56.1
> 

  reply	other threads:[~2026-12-01 12:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 10:49 [PATCH] cxgb4: use kstrtou16_from_user() in tp_la_write() Dmitry Antipov
2026-12-01 12:52 ` Potnuri Bharat Teja [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-08-14  6:41 Dmitry Antipov
2026-08-17 23:51 ` Jakub Kicinski

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=aw7DHYjaU3ntb8lU@chelsio.com \
    --to=bharat@chelsio.com \
    --cc=dmantipov@yandex.ru \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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