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