Commit 5b3df177 authored by Nikolay Aleksandrov's avatar Nikolay Aleksandrov Committed by David S. Miller

bonding: don't cast const buf in sysfs store

As was recently discussed [1], let's avoid casting the const buf in
bonding_sysfs_store_option and use kstrndup/kfree instead.

[1] http://lists.openwall.net/netdev/2018/07/22/25Signed-off-by: default avatarNikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fb42c838
...@@ -160,14 +160,19 @@ static ssize_t bonding_sysfs_store_option(struct device *d, ...@@ -160,14 +160,19 @@ static ssize_t bonding_sysfs_store_option(struct device *d,
{ {
struct bonding *bond = to_bond(d); struct bonding *bond = to_bond(d);
const struct bond_option *opt; const struct bond_option *opt;
char *buffer_clone;
int ret; int ret;
opt = bond_opt_get_by_name(attr->attr.name); opt = bond_opt_get_by_name(attr->attr.name);
if (WARN_ON(!opt)) if (WARN_ON(!opt))
return -ENOENT; return -ENOENT;
ret = bond_opt_tryset_rtnl(bond, opt->id, (char *)buffer); buffer_clone = kstrndup(buffer, count, GFP_KERNEL);
if (!buffer_clone)
return -ENOMEM;
ret = bond_opt_tryset_rtnl(bond, opt->id, buffer_clone);
if (!ret) if (!ret)
ret = count; ret = count;
kfree(buffer_clone);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment