File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -9687,14 +9687,17 @@ int bpf_xdp_link_attach(const union bpf_attr *attr, struct bpf_prog *prog)
9687
9687
struct net_device * dev ;
9688
9688
int err , fd ;
9689
9689
9690
+ rtnl_lock ();
9690
9691
dev = dev_get_by_index (net , attr -> link_create .target_ifindex );
9691
- if (!dev )
9692
+ if (!dev ) {
9693
+ rtnl_unlock ();
9692
9694
return - EINVAL ;
9695
+ }
9693
9696
9694
9697
link = kzalloc (sizeof (* link ), GFP_USER );
9695
9698
if (!link ) {
9696
9699
err = - ENOMEM ;
9697
- goto out_put_dev ;
9700
+ goto unlock_put_dev ;
9698
9701
}
9699
9702
9700
9703
bpf_link_init (& link -> link , BPF_LINK_TYPE_XDP , & bpf_xdp_link_lops , prog );
@@ -9704,10 +9707,9 @@ int bpf_xdp_link_attach(const union bpf_attr *attr, struct bpf_prog *prog)
9704
9707
err = bpf_link_prime (& link -> link , & link_primer );
9705
9708
if (err ) {
9706
9709
kfree (link );
9707
- goto out_put_dev ;
9710
+ goto unlock_put_dev ;
9708
9711
}
9709
9712
9710
- rtnl_lock ();
9711
9713
err = dev_xdp_attach_link (dev , NULL , link );
9712
9714
rtnl_unlock ();
9713
9715
@@ -9721,6 +9723,9 @@ int bpf_xdp_link_attach(const union bpf_attr *attr, struct bpf_prog *prog)
9721
9723
dev_put (dev );
9722
9724
return fd ;
9723
9725
9726
+ unlock_put_dev :
9727
+ rtnl_unlock ();
9728
+
9724
9729
out_put_dev :
9725
9730
dev_put (dev );
9726
9731
return err ;
You can’t perform that action at this time.
0 commit comments