netlink: Add nla_memdup() to wrap kmemdup() use on nlattr
Wrap several common instances of: kmemdup(nla_data(attr), nla_len(attr), GFP_KERNEL); Signed-off-by: Thomas Graf <tgraf@suug.ch> Acked-by: Johannes Berg <johannes@sipsolutions.net> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

vanhempi
f8da977989
commit
b15ca182ed
@@ -226,9 +226,7 @@ static int tcf_bpf_init_from_efd(struct nlattr **tb, struct tcf_bpf_cfg *cfg)
|
||||
return PTR_ERR(fp);
|
||||
|
||||
if (tb[TCA_ACT_BPF_NAME]) {
|
||||
name = kmemdup(nla_data(tb[TCA_ACT_BPF_NAME]),
|
||||
nla_len(tb[TCA_ACT_BPF_NAME]),
|
||||
GFP_KERNEL);
|
||||
name = nla_memdup(tb[TCA_ACT_BPF_NAME], GFP_KERNEL);
|
||||
if (!name) {
|
||||
bpf_prog_put(fp);
|
||||
return -ENOMEM;
|
||||
|
@@ -369,9 +369,7 @@ static int cls_bpf_prog_from_efd(struct nlattr **tb, struct cls_bpf_prog *prog,
|
||||
return PTR_ERR(fp);
|
||||
|
||||
if (tb[TCA_BPF_NAME]) {
|
||||
name = kmemdup(nla_data(tb[TCA_BPF_NAME]),
|
||||
nla_len(tb[TCA_BPF_NAME]),
|
||||
GFP_KERNEL);
|
||||
name = nla_memdup(tb[TCA_BPF_NAME], GFP_KERNEL);
|
||||
if (!name) {
|
||||
bpf_prog_put(fp);
|
||||
return -ENOMEM;
|
||||
|
@@ -10625,8 +10625,7 @@ static int handle_nan_filter(struct nlattr *attr_filter,
|
||||
|
||||
i = 0;
|
||||
nla_for_each_nested(attr, attr_filter, rem) {
|
||||
filter[i].filter = kmemdup(nla_data(attr), nla_len(attr),
|
||||
GFP_KERNEL);
|
||||
filter[i].filter = nla_memdup(attr, GFP_KERNEL);
|
||||
filter[i].len = nla_len(attr);
|
||||
i++;
|
||||
}
|
||||
|
Viittaa uudesa ongelmassa
Block a user