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)
96849684 struct net_device * dev ;
96859685 int err , fd ;
96869686
9687+ rtnl_lock ();
96879688 dev = dev_get_by_index (net , attr -> link_create .target_ifindex );
9688- if (!dev )
9689+ if (!dev ) {
9690+ rtnl_unlock ();
96899691 return - EINVAL ;
9692+ }
96909693
96919694 link = kzalloc (sizeof (* link ), GFP_USER );
96929695 if (!link ) {
96939696 err = - ENOMEM ;
9694- goto out_put_dev ;
9697+ goto unlock_put_dev ;
96959698 }
96969699
96979700 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)
97019704 err = bpf_link_prime (& link -> link , & link_primer );
97029705 if (err ) {
97039706 kfree (link );
9704- goto out_put_dev ;
9707+ goto unlock_put_dev ;
97059708 }
97069709
9707- rtnl_lock ();
97089710 err = dev_xdp_attach_link (dev , NULL , link );
97099711 rtnl_unlock ();
97109712
@@ -9718,6 +9720,9 @@ int bpf_xdp_link_attach(const union bpf_attr *attr, struct bpf_prog *prog)
97189720 dev_put (dev );
97199721 return fd ;
97209722
9723+ unlock_put_dev :
9724+ rtnl_unlock ();
9725+
97219726out_put_dev :
97229727 dev_put (dev );
97239728 return err ;
You can’t perform that action at this time.
0 commit comments