🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by Dmitry Antipov Fri, 20 Nov 2026 10:49
[PATCH] cxgb4: use kstrtou16_from_user() in tp_la_write()
#19772
Author: Dmitry Antipov
Date: Fri, 20 Nov 2026 10:49
38 lines
9377 bytes
Simplify tp_la_write() by using kstrtou16_from_user().

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads