net: bridge: replace simple_strtoul with kstrtoul
Subsystems (3)
PATCH v3 1/1 net: bridge: replace simple_strtoul with kstrtoul
The simple_strtoul() function is deprecated. It does not handle errors or overflows correctly. Replace it with kstrtoul() in brport_store() to ensure that invalid user input is caught and returned as an error.
Signed-off-by Aadarsh Chandra <[email protected]>
---
v3: move change log below the line and add Acked-by.
v2: target net-next and simplify by reusing the ret variable as
suggested by Nikolay Aleksandrov.
net/bridge/br_sysfs_if.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/bridge/br_sysfs_if.c +2 -3
@@ -318,7 +318,6 @@ static ssize_t brport_store(struct kobject *kobj,struct net_bridge_port *p =kobj_to_brport (kobj);ssize_t ret = -EINVAL ;unsigned long val; -char *endp;if (!ns_capable (dev_net (p->dev)->user_ns,CAP_NET_ADMIN ))return -EPERM ;
@@ -339,8 +338,8 @@ static ssize_t brport_store(struct kobject *kobj,spin_unlock_bh (&p->br->lock);kfree (buf_copy); }else if (brport_attr->store) { - val =simple_strtoul (buf, &endp,0 ); -if (endp == buf) + ret =kstrtoul (buf,0 , &val); +if (ret) goto out_unlock;spin_lock_bh (&p->br->lock); ret = brport_attr->store (p, val);
Signature · 1 line
2.54.0
Jakub Kicinski
maintainerQuoted 4 lines · On Wed, 6 May 2026 22:54:47 +0530 Aadarsh Chandra wrote:
The
simple_strtoul()function is deprecated. It does not handle errors or overflows correctly. Replace it withkstrtoul()inbrport_store()to ensure that invalid user input is caught and returned as an error.
Your email server (or something else in the pipe) is breaking the whitespace, this patch does not apply.
Signature · 1 line
pw-bot: cr