Skip to content

Commit e17c6d7

Browse files
saurabh-sengarrichardweinberger
authored andcommitted
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>
1 parent 70c8205 commit e17c6d7

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

‎arch/um/drivers/net_kern.c‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ static const struct net_device_ops uml_netdev_ops = {
388388
static int driver_registered;
389389

390390
static void eth_configure(int n, void *init, char *mac,
391-
struct transport *transport)
391+
struct transport *transport, gfp_t gfp_mask)
392392
{
393393
struct uml_net *device;
394394
struct net_device *dev;
@@ -397,7 +397,7 @@ static void eth_configure(int n, void *init, char *mac,
397397

398398
size = transport->private_size + sizeof(struct uml_net_private);
399399

400-
device = kzalloc(sizeof(*device), GFP_KERNEL);
400+
device = kzalloc(sizeof(*device), gfp_mask);
401401
if (device == NULL) {
402402
printk(KERN_ERR "eth_configure failed to allocate struct "
403403
"uml_net\n");
@@ -568,7 +568,7 @@ static LIST_HEAD(transports);
568568
static LIST_HEAD(eth_cmd_line);
569569

570570
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)
572572
{
573573
int len;
574574

@@ -582,7 +582,7 @@ static int check_transport(struct transport *transport, char *eth, int n,
582582
else if (*eth != '\0')
583583
return 0;
584584

585-
*init_out = kmalloc(transport->setup_size, GFP_KERNEL);
585+
*init_out = kmalloc(transport->setup_size, gfp_mask);
586586
if (*init_out == NULL)
587587
return 1;
588588

@@ -609,11 +609,11 @@ void register_transport(struct transport *new)
609609
list_for_each_safe(ele, next, &eth_cmd_line) {
610610
eth = list_entry(ele, struct eth_init, list);
611611
match = check_transport(new, eth->init, eth->index, &init,
612-
&mac);
612+
&mac, GFP_KERNEL);
613613
if (!match)
614614
continue;
615615
else if (init != NULL) {
616-
eth_configure(eth->index, init, mac, new);
616+
eth_configure(eth->index, init, mac, new, GFP_KERNEL);
617617
kfree(init);
618618
}
619619
list_del(&eth->list);
@@ -631,10 +631,11 @@ static int eth_setup_common(char *str, int index)
631631
spin_lock(&transports_lock);
632632
list_for_each(ele, &transports) {
633633
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))
635636
continue;
636637
if (init != NULL) {
637-
eth_configure(index, init, mac, transport);
638+
eth_configure(index, init, mac, transport, GFP_ATOMIC);
638639
kfree(init);
639640
}
640641
found = 1;

0 commit comments

Comments
 (0)