File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-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)
96879687 struct net_device * dev ;
96889688 int err , fd ;
96899689
9690+ rtnl_lock ();
96909691 dev = dev_get_by_index (net , attr -> link_create .target_ifindex );
9691- if (!dev )
9692+ if (!dev ) {
9693+ rtnl_unlock ();
96929694 return - EINVAL ;
9695+ }
96939696
96949697 link = kzalloc (sizeof (* link ), GFP_USER );
96959698 if (!link ) {
96969699 err = - ENOMEM ;
9697- goto out_put_dev ;
9700+ goto unlock ;
96989701 }
96999702
97009703 bpf_link_init (& link -> link , BPF_LINK_TYPE_XDP , & bpf_xdp_link_lops , prog );
@@ -9704,14 +9707,14 @@ int bpf_xdp_link_attach(const union bpf_attr *attr, struct bpf_prog *prog)
97049707 err = bpf_link_prime (& link -> link , & link_primer );
97059708 if (err ) {
97069709 kfree (link );
9707- goto out_put_dev ;
9710+ goto unlock ;
97089711 }
97099712
9710- rtnl_lock ();
97119713 err = dev_xdp_attach_link (dev , NULL , link );
97129714 rtnl_unlock ();
97139715
97149716 if (err ) {
9717+ link -> dev = NULL ;
97159718 bpf_link_cleanup (& link_primer );
97169719 goto out_put_dev ;
97179720 }
@@ -9721,6 +9724,9 @@ int bpf_xdp_link_attach(const union bpf_attr *attr, struct bpf_prog *prog)
97219724 dev_put (dev );
97229725 return fd ;
97239726
9727+ unlock :
9728+ rtnl_unlock ();
9729+
97249730out_put_dev :
97259731 dev_put (dev );
97269732 return err ;
You can’t perform that action at this time.
0 commit comments