diff options
-rw-r--r-- | include/net/netlink.h | 10 | ||||
-rw-r--r-- | net/sched/act_bpf.c | 4 | ||||
-rw-r--r-- | net/sched/cls_bpf.c | 4 | ||||
-rw-r--r-- | net/wireless/nl80211.c | 3 |
4 files changed, 13 insertions, 8 deletions
diff --git a/include/net/netlink.h b/include/net/netlink.h index 254a0fc01800..a34f53acb6d6 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h | |||
@@ -1191,6 +1191,16 @@ static inline struct in6_addr nla_get_in6_addr(const struct nlattr *nla) | |||
1191 | } | 1191 | } |
1192 | 1192 | ||
1193 | /** | 1193 | /** |
1194 | * nla_memdup - duplicate attribute memory (kmemdup) | ||
1195 | * @src: netlink attribute to duplicate from | ||
1196 | * @gfp: GFP mask | ||
1197 | */ | ||
1198 | static inline void *nla_memdup(const struct nlattr *src, gfp_t gfp) | ||
1199 | { | ||
1200 | return kmemdup(nla_data(src), nla_len(src), gfp); | ||
1201 | } | ||
1202 | |||
1203 | /** | ||
1194 | * nla_nest_start - Start a new level of nested attributes | 1204 | * nla_nest_start - Start a new level of nested attributes |
1195 | * @skb: socket buffer to add attributes to | 1205 | * @skb: socket buffer to add attributes to |
1196 | * @attrtype: attribute type of container | 1206 | * @attrtype: attribute type of container |
diff --git a/net/sched/act_bpf.c b/net/sched/act_bpf.c index 1d3960033f61..9ff06cfbcdec 100644 --- a/net/sched/act_bpf.c +++ b/net/sched/act_bpf.c | |||
@@ -226,9 +226,7 @@ static int tcf_bpf_init_from_efd(struct nlattr **tb, struct tcf_bpf_cfg *cfg) | |||
226 | return PTR_ERR(fp); | 226 | return PTR_ERR(fp); |
227 | 227 | ||
228 | if (tb[TCA_ACT_BPF_NAME]) { | 228 | if (tb[TCA_ACT_BPF_NAME]) { |
229 | name = kmemdup(nla_data(tb[TCA_ACT_BPF_NAME]), | 229 | name = nla_memdup(tb[TCA_ACT_BPF_NAME], GFP_KERNEL); |
230 | nla_len(tb[TCA_ACT_BPF_NAME]), | ||
231 | GFP_KERNEL); | ||
232 | if (!name) { | 230 | if (!name) { |
233 | bpf_prog_put(fp); | 231 | bpf_prog_put(fp); |
234 | return -ENOMEM; | 232 | return -ENOMEM; |
diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c index bb1d5a487081..52dc85acca7d 100644 --- a/net/sched/cls_bpf.c +++ b/net/sched/cls_bpf.c | |||
@@ -369,9 +369,7 @@ static int cls_bpf_prog_from_efd(struct nlattr **tb, struct cls_bpf_prog *prog, | |||
369 | return PTR_ERR(fp); | 369 | return PTR_ERR(fp); |
370 | 370 | ||
371 | if (tb[TCA_BPF_NAME]) { | 371 | if (tb[TCA_BPF_NAME]) { |
372 | name = kmemdup(nla_data(tb[TCA_BPF_NAME]), | 372 | name = nla_memdup(tb[TCA_BPF_NAME], GFP_KERNEL); |
373 | nla_len(tb[TCA_BPF_NAME]), | ||
374 | GFP_KERNEL); | ||
375 | if (!name) { | 373 | if (!name) { |
376 | bpf_prog_put(fp); | 374 | bpf_prog_put(fp); |
377 | return -ENOMEM; | 375 | return -ENOMEM; |
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 271707dacfea..0d3ab4bfeacf 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -10625,8 +10625,7 @@ static int handle_nan_filter(struct nlattr *attr_filter, | |||
10625 | 10625 | ||
10626 | i = 0; | 10626 | i = 0; |
10627 | nla_for_each_nested(attr, attr_filter, rem) { | 10627 | nla_for_each_nested(attr, attr_filter, rem) { |
10628 | filter[i].filter = kmemdup(nla_data(attr), nla_len(attr), | 10628 | filter[i].filter = nla_memdup(attr, GFP_KERNEL); |
10629 | GFP_KERNEL); | ||
10630 | filter[i].len = nla_len(attr); | 10629 | filter[i].len = nla_len(attr); |
10631 | i++; | 10630 | i++; |
10632 | } | 10631 | } |