@@ -102,6 +102,7 @@ struct netconsole_target {
102
102
struct config_item item ;
103
103
#endif
104
104
int enabled ;
105
+ struct mutex mutex ;
105
106
struct netpoll np ;
106
107
};
107
108
@@ -181,6 +182,7 @@ static struct netconsole_target *alloc_param_target(char *target_config)
181
182
strlcpy (nt -> np .dev_name , "eth0" , IFNAMSIZ );
182
183
nt -> np .local_port = 6665 ;
183
184
nt -> np .remote_port = 6666 ;
185
+ mutex_init (& nt -> mutex );
184
186
memset (nt -> np .remote_mac , 0xff , ETH_ALEN );
185
187
186
188
/* Parse parameters and setup netpoll */
@@ -322,6 +324,7 @@ static ssize_t store_enabled(struct netconsole_target *nt,
322
324
return - EINVAL ;
323
325
}
324
326
327
+ mutex_lock (& nt -> mutex );
325
328
if (enabled ) { /* 1 */
326
329
327
330
/*
@@ -331,8 +334,10 @@ static ssize_t store_enabled(struct netconsole_target *nt,
331
334
netpoll_print_options (& nt -> np );
332
335
333
336
err = netpoll_setup (& nt -> np );
334
- if (err )
337
+ if (err ) {
338
+ mutex_unlock (& nt -> mutex );
335
339
return err ;
340
+ }
336
341
337
342
printk (KERN_INFO "netconsole: network logging started\n" );
338
343
@@ -341,6 +346,7 @@ static ssize_t store_enabled(struct netconsole_target *nt,
341
346
}
342
347
343
348
nt -> enabled = enabled ;
349
+ mutex_unlock (& nt -> mutex );
344
350
345
351
return strnlen (buf , count );
346
352
}
@@ -597,6 +603,7 @@ static struct config_item *make_netconsole_target(struct config_group *group,
597
603
strlcpy (nt -> np .dev_name , "eth0" , IFNAMSIZ );
598
604
nt -> np .local_port = 6665 ;
599
605
nt -> np .remote_port = 6666 ;
606
+ mutex_init (& nt -> mutex );
600
607
memset (nt -> np .remote_mac , 0xff , ETH_ALEN );
601
608
602
609
/* Initialize the config_item member */
@@ -682,7 +689,11 @@ static int netconsole_netdev_event(struct notifier_block *this,
682
689
* we might sleep in __netpoll_cleanup()
683
690
*/
684
691
spin_unlock_irqrestore (& target_list_lock , flags );
692
+
693
+ mutex_lock (& nt -> mutex );
685
694
__netpoll_cleanup (& nt -> np );
695
+ mutex_unlock (& nt -> mutex );
696
+
686
697
spin_lock_irqsave (& target_list_lock , flags );
687
698
dev_put (nt -> np .dev );
688
699
nt -> np .dev = NULL ;
0 commit comments