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 @@ -9700,14 +9700,17 @@ int bpf_xdp_link_attach(const union bpf_attr *attr, struct bpf_prog *prog)
97009700 struct net_device * dev ;
97019701 int err , fd ;
97029702
9703+ rtnl_lock ();
97039704 dev = dev_get_by_index (net , attr -> link_create .target_ifindex );
9704- if (!dev )
9705+ if (!dev ) {
9706+ rtnl_unlock ();
97059707 return - EINVAL ;
9708+ }
97069709
97079710 link = kzalloc (sizeof (* link ), GFP_USER );
97089711 if (!link ) {
97099712 err = - ENOMEM ;
9710- goto out_put_dev ;
9713+ goto unlock ;
97119714 }
97129715
97139716 bpf_link_init (& link -> link , BPF_LINK_TYPE_XDP , & bpf_xdp_link_lops , prog );
@@ -9717,14 +9720,14 @@ int bpf_xdp_link_attach(const union bpf_attr *attr, struct bpf_prog *prog)
97179720 err = bpf_link_prime (& link -> link , & link_primer );
97189721 if (err ) {
97199722 kfree (link );
9720- goto out_put_dev ;
9723+ goto unlock ;
97219724 }
97229725
9723- rtnl_lock ();
97249726 err = dev_xdp_attach_link (dev , NULL , link );
97259727 rtnl_unlock ();
97269728
97279729 if (err ) {
9730+ link -> dev = NULL ;
97289731 bpf_link_cleanup (& link_primer );
97299732 goto out_put_dev ;
97309733 }
@@ -9734,6 +9737,9 @@ int bpf_xdp_link_attach(const union bpf_attr *attr, struct bpf_prog *prog)
97349737 dev_put (dev );
97359738 return fd ;
97369739
9740+ unlock :
9741+ rtnl_unlock ();
9742+
97379743out_put_dev :
97389744 dev_put (dev );
97399745 return err ;
You can’t perform that action at this time.
0 commit comments