diff options
| author | Saurabh Sengar <saurabh.truth@gmail.com> | 2015-10-29 11:30:32 -0400 |
|---|---|---|
| committer | Richard Weinberger <richard@nod.at> | 2015-11-06 16:51:00 -0500 |
| commit | e17c6d77b28c6feab446ad6eaec865e8031ed616 (patch) | |
| tree | 1cbb33b55e1d5715d2b379b43f83045b30373662 /arch/um | |
| parent | 70c8205f40a385383b0c81f59550cf27273bf912 (diff) | |
um: net: replace GFP_KERNEL with GFP_ATOMIC when spinlock is held
since GFP_KERNEL with GFP_ATOMIC while spinlock is held,
as code while holding a spinlock should be atomic.
GFP_KERNEL may sleep and can cause deadlock,
where as GFP_ATOMIC may fail but certainly avoids deadlockdex f70dd54..d898f6c 100644
Signed-off-by: Saurabh Sengar <saurabh.truth@gmail.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'arch/um')
| -rw-r--r-- | arch/um/drivers/net_kern.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c index f70dd540655d..9ef669d24bb2 100644 --- a/arch/um/drivers/net_kern.c +++ b/arch/um/drivers/net_kern.c | |||
| @@ -388,7 +388,7 @@ static const struct net_device_ops uml_netdev_ops = { | |||
| 388 | static int driver_registered; | 388 | static int driver_registered; |
| 389 | 389 | ||
| 390 | static void eth_configure(int n, void *init, char *mac, | 390 | static void eth_configure(int n, void *init, char *mac, |
| 391 | struct transport *transport) | 391 | struct transport *transport, gfp_t gfp_mask) |
| 392 | { | 392 | { |
| 393 | struct uml_net *device; | 393 | struct uml_net *device; |
| 394 | struct net_device *dev; | 394 | struct net_device *dev; |
| @@ -397,7 +397,7 @@ static void eth_configure(int n, void *init, char *mac, | |||
| 397 | 397 | ||
| 398 | size = transport->private_size + sizeof(struct uml_net_private); | 398 | size = transport->private_size + sizeof(struct uml_net_private); |
| 399 | 399 | ||
| 400 | device = kzalloc(sizeof(*device), GFP_KERNEL); | 400 | device = kzalloc(sizeof(*device), gfp_mask); |
| 401 | if (device == NULL) { | 401 | if (device == NULL) { |
| 402 | printk(KERN_ERR "eth_configure failed to allocate struct " | 402 | printk(KERN_ERR "eth_configure failed to allocate struct " |
| 403 | "uml_net\n"); | 403 | "uml_net\n"); |
| @@ -568,7 +568,7 @@ static LIST_HEAD(transports); | |||
| 568 | static LIST_HEAD(eth_cmd_line); | 568 | static LIST_HEAD(eth_cmd_line); |
| 569 | 569 | ||
| 570 | static int check_transport(struct transport *transport, char *eth, int n, | 570 | static int check_transport(struct transport *transport, char *eth, int n, |
| 571 | void **init_out, char **mac_out) | 571 | void **init_out, char **mac_out, gfp_t gfp_mask) |
| 572 | { | 572 | { |
| 573 | int len; | 573 | int len; |
| 574 | 574 | ||
| @@ -582,7 +582,7 @@ static int check_transport(struct transport *transport, char *eth, int n, | |||
| 582 | else if (*eth != '\0') | 582 | else if (*eth != '\0') |
| 583 | return 0; | 583 | return 0; |
| 584 | 584 | ||
| 585 | *init_out = kmalloc(transport->setup_size, GFP_KERNEL); | 585 | *init_out = kmalloc(transport->setup_size, gfp_mask); |
| 586 | if (*init_out == NULL) | 586 | if (*init_out == NULL) |
| 587 | return 1; | 587 | return 1; |
| 588 | 588 | ||
| @@ -609,11 +609,11 @@ void register_transport(struct transport *new) | |||
| 609 | list_for_each_safe(ele, next, ð_cmd_line) { | 609 | list_for_each_safe(ele, next, ð_cmd_line) { |
| 610 | eth = list_entry(ele, struct eth_init, list); | 610 | eth = list_entry(ele, struct eth_init, list); |
| 611 | match = check_transport(new, eth->init, eth->index, &init, | 611 | match = check_transport(new, eth->init, eth->index, &init, |
| 612 | &mac); | 612 | &mac, GFP_KERNEL); |
| 613 | if (!match) | 613 | if (!match) |
| 614 | continue; | 614 | continue; |
| 615 | else if (init != NULL) { | 615 | else if (init != NULL) { |
| 616 | eth_configure(eth->index, init, mac, new); | 616 | eth_configure(eth->index, init, mac, new, GFP_KERNEL); |
| 617 | kfree(init); | 617 | kfree(init); |
| 618 | } | 618 | } |
| 619 | list_del(ð->list); | 619 | list_del(ð->list); |
| @@ -631,10 +631,11 @@ static int eth_setup_common(char *str, int index) | |||
| 631 | spin_lock(&transports_lock); | 631 | spin_lock(&transports_lock); |
| 632 | list_for_each(ele, &transports) { | 632 | list_for_each(ele, &transports) { |
| 633 | transport = list_entry(ele, struct transport, list); | 633 | transport = list_entry(ele, struct transport, list); |
| 634 | if (!check_transport(transport, str, index, &init, &mac)) | 634 | if (!check_transport(transport, str, index, &init, |
| 635 | &mac, GFP_ATOMIC)) | ||
| 635 | continue; | 636 | continue; |
| 636 | if (init != NULL) { | 637 | if (init != NULL) { |
| 637 | eth_configure(index, init, mac, transport); | 638 | eth_configure(index, init, mac, transport, GFP_ATOMIC); |
| 638 | kfree(init); | 639 | kfree(init); |
| 639 | } | 640 | } |
| 640 | found = 1; | 641 | found = 1; |
