diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2006-12-14 18:52:13 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-12-18 00:59:14 -0500 |
commit | a3d384029aa304f8f3f5355d35f0ae274454f7cd (patch) | |
tree | 6bdb628b439cde292317fa5e89e14977899855a5 /net/rose | |
parent | a159aaa328a02b0189774c58ae7d917b25d26852 (diff) |
[AX.25]: Fix unchecked rose_add_loopback_neigh uses
rose_add_loopback_neigh uses kmalloc and the callers were ignoring the
error value. Rewrite to let the caller deal with the allocation. This
allows the use of static allocation of kmalloc use entirely.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/rose')
-rw-r--r-- | net/rose/rose_loopback.c | 5 | ||||
-rw-r--r-- | net/rose/rose_route.c | 45 |
2 files changed, 24 insertions, 26 deletions
diff --git a/net/rose/rose_loopback.c b/net/rose/rose_loopback.c index 103b4d38f88a..3e41bd93ab9f 100644 --- a/net/rose/rose_loopback.c +++ b/net/rose/rose_loopback.c | |||
@@ -79,7 +79,8 @@ static void rose_loopback_timer(unsigned long param) | |||
79 | 79 | ||
80 | skb->h.raw = skb->data; | 80 | skb->h.raw = skb->data; |
81 | 81 | ||
82 | if ((sk = rose_find_socket(lci_o, rose_loopback_neigh)) != NULL) { | 82 | sk = rose_find_socket(lci_o, &rose_loopback_neigh); |
83 | if (sk) { | ||
83 | if (rose_process_rx_frame(sk, skb) == 0) | 84 | if (rose_process_rx_frame(sk, skb) == 0) |
84 | kfree_skb(skb); | 85 | kfree_skb(skb); |
85 | continue; | 86 | continue; |
@@ -87,7 +88,7 @@ static void rose_loopback_timer(unsigned long param) | |||
87 | 88 | ||
88 | if (frametype == ROSE_CALL_REQUEST) { | 89 | if (frametype == ROSE_CALL_REQUEST) { |
89 | if ((dev = rose_dev_get(dest)) != NULL) { | 90 | if ((dev = rose_dev_get(dest)) != NULL) { |
90 | if (rose_rx_call_request(skb, dev, rose_loopback_neigh, lci_o) == 0) | 91 | if (rose_rx_call_request(skb, dev, &rose_loopback_neigh, lci_o) == 0) |
91 | kfree_skb(skb); | 92 | kfree_skb(skb); |
92 | } else { | 93 | } else { |
93 | kfree_skb(skb); | 94 | kfree_skb(skb); |
diff --git a/net/rose/rose_route.c b/net/rose/rose_route.c index d02985b00a20..8028c0d425dc 100644 --- a/net/rose/rose_route.c +++ b/net/rose/rose_route.c | |||
@@ -46,7 +46,7 @@ static DEFINE_SPINLOCK(rose_neigh_list_lock); | |||
46 | static struct rose_route *rose_route_list; | 46 | static struct rose_route *rose_route_list; |
47 | static DEFINE_SPINLOCK(rose_route_list_lock); | 47 | static DEFINE_SPINLOCK(rose_route_list_lock); |
48 | 48 | ||
49 | struct rose_neigh *rose_loopback_neigh; | 49 | struct rose_neigh rose_loopback_neigh; |
50 | 50 | ||
51 | /* | 51 | /* |
52 | * Add a new route to a node, and in the process add the node and the | 52 | * Add a new route to a node, and in the process add the node and the |
@@ -361,33 +361,30 @@ out: | |||
361 | /* | 361 | /* |
362 | * Add the loopback neighbour. | 362 | * Add the loopback neighbour. |
363 | */ | 363 | */ |
364 | int rose_add_loopback_neigh(void) | 364 | void rose_add_loopback_neigh(void) |
365 | { | 365 | { |
366 | if ((rose_loopback_neigh = kmalloc(sizeof(struct rose_neigh), GFP_ATOMIC)) == NULL) | 366 | struct rose_neigh *sn = &rose_loopback_neigh; |
367 | return -ENOMEM; | ||
368 | 367 | ||
369 | rose_loopback_neigh->callsign = null_ax25_address; | 368 | sn->callsign = null_ax25_address; |
370 | rose_loopback_neigh->digipeat = NULL; | 369 | sn->digipeat = NULL; |
371 | rose_loopback_neigh->ax25 = NULL; | 370 | sn->ax25 = NULL; |
372 | rose_loopback_neigh->dev = NULL; | 371 | sn->dev = NULL; |
373 | rose_loopback_neigh->count = 0; | 372 | sn->count = 0; |
374 | rose_loopback_neigh->use = 0; | 373 | sn->use = 0; |
375 | rose_loopback_neigh->dce_mode = 1; | 374 | sn->dce_mode = 1; |
376 | rose_loopback_neigh->loopback = 1; | 375 | sn->loopback = 1; |
377 | rose_loopback_neigh->number = rose_neigh_no++; | 376 | sn->number = rose_neigh_no++; |
378 | rose_loopback_neigh->restarted = 1; | 377 | sn->restarted = 1; |
379 | 378 | ||
380 | skb_queue_head_init(&rose_loopback_neigh->queue); | 379 | skb_queue_head_init(&sn->queue); |
381 | 380 | ||
382 | init_timer(&rose_loopback_neigh->ftimer); | 381 | init_timer(&sn->ftimer); |
383 | init_timer(&rose_loopback_neigh->t0timer); | 382 | init_timer(&sn->t0timer); |
384 | 383 | ||
385 | spin_lock_bh(&rose_neigh_list_lock); | 384 | spin_lock_bh(&rose_neigh_list_lock); |
386 | rose_loopback_neigh->next = rose_neigh_list; | 385 | sn->next = rose_neigh_list; |
387 | rose_neigh_list = rose_loopback_neigh; | 386 | rose_neigh_list = sn; |
388 | spin_unlock_bh(&rose_neigh_list_lock); | 387 | spin_unlock_bh(&rose_neigh_list_lock); |
389 | |||
390 | return 0; | ||
391 | } | 388 | } |
392 | 389 | ||
393 | /* | 390 | /* |
@@ -421,13 +418,13 @@ int rose_add_loopback_node(rose_address *address) | |||
421 | rose_node->mask = 10; | 418 | rose_node->mask = 10; |
422 | rose_node->count = 1; | 419 | rose_node->count = 1; |
423 | rose_node->loopback = 1; | 420 | rose_node->loopback = 1; |
424 | rose_node->neighbour[0] = rose_loopback_neigh; | 421 | rose_node->neighbour[0] = &rose_loopback_neigh; |
425 | 422 | ||
426 | /* Insert at the head of list. Address is always mask=10 */ | 423 | /* Insert at the head of list. Address is always mask=10 */ |
427 | rose_node->next = rose_node_list; | 424 | rose_node->next = rose_node_list; |
428 | rose_node_list = rose_node; | 425 | rose_node_list = rose_node; |
429 | 426 | ||
430 | rose_loopback_neigh->count++; | 427 | rose_loopback_neigh.count++; |
431 | 428 | ||
432 | out: | 429 | out: |
433 | spin_unlock_bh(&rose_node_list_lock); | 430 | spin_unlock_bh(&rose_node_list_lock); |
@@ -458,7 +455,7 @@ void rose_del_loopback_node(rose_address *address) | |||
458 | 455 | ||
459 | rose_remove_node(rose_node); | 456 | rose_remove_node(rose_node); |
460 | 457 | ||
461 | rose_loopback_neigh->count--; | 458 | rose_loopback_neigh.count--; |
462 | 459 | ||
463 | out: | 460 | out: |
464 | spin_unlock_bh(&rose_node_list_lock); | 461 | spin_unlock_bh(&rose_node_list_lock); |