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 @@ -9684,14 +9684,17 @@ int bpf_xdp_link_attach(const union bpf_attr *attr, struct bpf_prog *prog)
9684
9684
struct net_device * dev ;
9685
9685
int err , fd ;
9686
9686
9687
+ rtnl_lock ();
9687
9688
dev = dev_get_by_index (net , attr -> link_create .target_ifindex );
9688
- if (!dev )
9689
+ if (!dev ) {
9690
+ rtnl_unlock ();
9689
9691
return - EINVAL ;
9692
+ }
9690
9693
9691
9694
link = kzalloc (sizeof (* link ), GFP_USER );
9692
9695
if (!link ) {
9693
9696
err = - ENOMEM ;
9694
- goto out_put_dev ;
9697
+ goto unlock_put_dev ;
9695
9698
}
9696
9699
9697
9700
bpf_link_init (& link -> link , BPF_LINK_TYPE_XDP , & bpf_xdp_link_lops , prog );
@@ -9701,10 +9704,9 @@ int bpf_xdp_link_attach(const union bpf_attr *attr, struct bpf_prog *prog)
9701
9704
err = bpf_link_prime (& link -> link , & link_primer );
9702
9705
if (err ) {
9703
9706
kfree (link );
9704
- goto out_put_dev ;
9707
+ goto unlock_put_dev ;
9705
9708
}
9706
9709
9707
- rtnl_lock ();
9708
9710
err = dev_xdp_attach_link (dev , NULL , link );
9709
9711
rtnl_unlock ();
9710
9712
@@ -9718,6 +9720,9 @@ int bpf_xdp_link_attach(const union bpf_attr *attr, struct bpf_prog *prog)
9718
9720
dev_put (dev );
9719
9721
return fd ;
9720
9722
9723
+ unlock_put_dev :
9724
+ rtnl_unlock ();
9725
+
9721
9726
out_put_dev :
9722
9727
dev_put (dev );
9723
9728
return err ;
You can’t perform that action at this time.
0 commit comments