@@ -124,6 +124,7 @@ static unsigned char bus_mac[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
124
124
125
125
/* Device structures */
126
126
static struct net_device * dev_lec [MAX_LEC_ITF ];
127
+ static DEFINE_MUTEX (lec_mutex );
127
128
128
129
#if IS_ENABLED (CONFIG_BRIDGE )
129
130
static void lec_handle_bridge (struct sk_buff * skb , struct net_device * dev )
@@ -685,6 +686,7 @@ static int lec_vcc_attach(struct atm_vcc *vcc, void __user *arg)
685
686
int bytes_left ;
686
687
struct atmlec_ioc ioc_data ;
687
688
689
+ lockdep_assert_held (& lec_mutex );
688
690
/* Lecd must be up in this case */
689
691
bytes_left = copy_from_user (& ioc_data , arg , sizeof (struct atmlec_ioc ));
690
692
if (bytes_left != 0 )
@@ -710,6 +712,7 @@ static int lec_vcc_attach(struct atm_vcc *vcc, void __user *arg)
710
712
711
713
static int lec_mcast_attach (struct atm_vcc * vcc , int arg )
712
714
{
715
+ lockdep_assert_held (& lec_mutex );
713
716
if (arg < 0 || arg >= MAX_LEC_ITF )
714
717
return - EINVAL ;
715
718
arg = array_index_nospec (arg , MAX_LEC_ITF );
@@ -725,6 +728,7 @@ static int lecd_attach(struct atm_vcc *vcc, int arg)
725
728
int i ;
726
729
struct lec_priv * priv ;
727
730
731
+ lockdep_assert_held (& lec_mutex );
728
732
if (arg < 0 )
729
733
arg = 0 ;
730
734
if (arg >= MAX_LEC_ITF )
@@ -742,6 +746,7 @@ static int lecd_attach(struct atm_vcc *vcc, int arg)
742
746
snprintf (dev_lec [i ]-> name , IFNAMSIZ , "lec%d" , i );
743
747
if (register_netdev (dev_lec [i ])) {
744
748
free_netdev (dev_lec [i ]);
749
+ dev_lec [i ] = NULL ;
745
750
return - EINVAL ;
746
751
}
747
752
@@ -904,7 +909,6 @@ static void *lec_itf_walk(struct lec_state *state, loff_t *l)
904
909
v = (dev && netdev_priv (dev )) ?
905
910
lec_priv_walk (state , l , netdev_priv (dev )) : NULL ;
906
911
if (!v && dev ) {
907
- dev_put (dev );
908
912
/* Partial state reset for the next time we get called */
909
913
dev = NULL ;
910
914
}
@@ -928,6 +932,7 @@ static void *lec_seq_start(struct seq_file *seq, loff_t *pos)
928
932
{
929
933
struct lec_state * state = seq -> private ;
930
934
935
+ mutex_lock (& lec_mutex );
931
936
state -> itf = 0 ;
932
937
state -> dev = NULL ;
933
938
state -> locked = NULL ;
@@ -945,8 +950,9 @@ static void lec_seq_stop(struct seq_file *seq, void *v)
945
950
if (state -> dev ) {
946
951
spin_unlock_irqrestore (& state -> locked -> lec_arp_lock ,
947
952
state -> flags );
948
- dev_put ( state -> dev ) ;
953
+ state -> dev = NULL ;
949
954
}
955
+ mutex_unlock (& lec_mutex );
950
956
}
951
957
952
958
static void * lec_seq_next (struct seq_file * seq , void * v , loff_t * pos )
@@ -1003,6 +1009,7 @@ static int lane_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1003
1009
return - ENOIOCTLCMD ;
1004
1010
}
1005
1011
1012
+ mutex_lock (& lec_mutex );
1006
1013
switch (cmd ) {
1007
1014
case ATMLEC_CTRL :
1008
1015
err = lecd_attach (vcc , (int )arg );
@@ -1017,6 +1024,7 @@ static int lane_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1017
1024
break ;
1018
1025
}
1019
1026
1027
+ mutex_unlock (& lec_mutex );
1020
1028
return err ;
1021
1029
}
1022
1030
0 commit comments