* [PATCH 2.6.19-rc2] [REVISED] net/ipv4/multipath_wrandom.c: check kmalloc() return value.
@ 2006-10-23 6:59 Amit Choudhary
2006-10-23 7:46 ` James Morris
2006-10-23 11:17 ` Patrick McHardy
0 siblings, 2 replies; 3+ messages in thread
From: Amit Choudhary @ 2006-10-23 6:59 UTC (permalink / raw)
To: Linux Kernel, akpm; +Cc: netdev
Description: Check the return value of kmalloc() in function wrandom_set_nhinfo(), in file net/ipv4/multipath_wrandom.c.
Signed-off-by: Amit Choudhary <amit2030@gmail.com>
diff --git a/net/ipv4/multipath_wrandom.c b/net/ipv4/multipath_wrandom.c
index 92b0482..bcdb1f1 100644
--- a/net/ipv4/multipath_wrandom.c
+++ b/net/ipv4/multipath_wrandom.c
@@ -242,6 +242,9 @@ static void wrandom_set_nhinfo(__be32 ne
target_route = (struct multipath_route *)
kmalloc(size_rt, GFP_ATOMIC);
+ if (!target_route)
+ goto error;
+
target_route->gw = nh->nh_gw;
target_route->oif = nh->nh_oif;
memset(&target_route->rcu, 0, sizeof(struct rcu_head));
@@ -263,6 +266,9 @@ static void wrandom_set_nhinfo(__be32 ne
target_dest = (struct multipath_dest*)
kmalloc(size_dst, GFP_ATOMIC);
+ if (!target_dest)
+ goto error;
+
target_dest->nh_info = nh;
target_dest->network = network;
target_dest->netmask = netmask;
@@ -275,6 +281,7 @@ static void wrandom_set_nhinfo(__be32 ne
* we are finished
*/
+ error:
spin_unlock_bh(&state[state_idx].lock);
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2.6.19-rc2] [REVISED] net/ipv4/multipath_wrandom.c: check kmalloc() return value.
2006-10-23 6:59 [PATCH 2.6.19-rc2] [REVISED] net/ipv4/multipath_wrandom.c: check kmalloc() return value Amit Choudhary
@ 2006-10-23 7:46 ` James Morris
2006-10-23 11:17 ` Patrick McHardy
1 sibling, 0 replies; 3+ messages in thread
From: James Morris @ 2006-10-23 7:46 UTC (permalink / raw)
To: Amit Choudhary; +Cc: Linux Kernel, akpm, netdev
On Sun, 22 Oct 2006, Amit Choudhary wrote:
> Description: Check the return value of kmalloc() in function wrandom_set_nhinfo(), in file net/ipv4/multipath_wrandom.c.
>
> Signed-off-by: Amit Choudhary <amit2030@gmail.com>
Acked-by: James Morris <jmorris@namei.org>
> @@ -242,6 +242,9 @@ static void wrandom_set_nhinfo(__be32 ne
> target_route = (struct multipath_route *)
> kmalloc(size_rt, GFP_ATOMIC);
It'd be nice to see these casts removed in a future cleanup.
- James
--
James Morris
<jmorris@namei.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2.6.19-rc2] [REVISED] net/ipv4/multipath_wrandom.c: check kmalloc() return value.
2006-10-23 6:59 [PATCH 2.6.19-rc2] [REVISED] net/ipv4/multipath_wrandom.c: check kmalloc() return value Amit Choudhary
2006-10-23 7:46 ` James Morris
@ 2006-10-23 11:17 ` Patrick McHardy
1 sibling, 0 replies; 3+ messages in thread
From: Patrick McHardy @ 2006-10-23 11:17 UTC (permalink / raw)
To: Amit Choudhary; +Cc: Linux Kernel, akpm, netdev
[-- Attachment #1: Type: text/plain, Size: 1510 bytes --]
Amit Choudhary wrote:
> Description: Check the return value of kmalloc() in function wrandom_set_nhinfo(), in file net/ipv4/multipath_wrandom.c.
>
> Signed-off-by: Amit Choudhary <amit2030@gmail.com>
>
> diff --git a/net/ipv4/multipath_wrandom.c b/net/ipv4/multipath_wrandom.c
> index 92b0482..bcdb1f1 100644
> --- a/net/ipv4/multipath_wrandom.c
> +++ b/net/ipv4/multipath_wrandom.c
> @@ -242,6 +242,9 @@ static void wrandom_set_nhinfo(__be32 ne
> target_route = (struct multipath_route *)
> kmalloc(size_rt, GFP_ATOMIC);
>
> + if (!target_route)
> + goto error;
> +
> target_route->gw = nh->nh_gw;
> target_route->oif = nh->nh_oif;
> memset(&target_route->rcu, 0, sizeof(struct rcu_head));
> @@ -263,6 +266,9 @@ static void wrandom_set_nhinfo(__be32 ne
> target_dest = (struct multipath_dest*)
> kmalloc(size_dst, GFP_ATOMIC);
>
> + if (!target_dest)
> + goto error;
> +
>
> target_dest->nh_info = nh;
> target_dest->network = network;
> target_dest->netmask = netmask;
> @@ -275,6 +281,7 @@ static void wrandom_set_nhinfo(__be32 ne
> * we are finished
> */
>
> + error:
> spin_unlock_bh(&state[state_idx].lock);
> }
Thats slightly better than before, but since no errors are propagated
back to the routing code I think it would still crash later on.
A better idea would be to mark this crap BROKEN until it is really
fixed, so people won't accidentally enable it (which is enough
to cause problems).
Signed-off-by: Patrick McHardy <kaber@trash.net>
[-- Attachment #2: x --]
[-- Type: text/plain, Size: 591 bytes --]
diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig
index 5572071..9ff5616 100644
--- a/net/ipv4/Kconfig
+++ b/net/ipv4/Kconfig
@@ -124,8 +124,8 @@ config IP_ROUTE_MULTIPATH
if a matching packet arrives.
config IP_ROUTE_MULTIPATH_CACHED
- bool "IP: equal cost multipath with caching support (EXPERIMENTAL)"
- depends on IP_ROUTE_MULTIPATH
+ bool "IP: equal cost multipath with caching support (BROKEN)"
+ depends on IP_ROUTE_MULTIPATH && BROKEN
help
Normally, equal cost multipath routing is not supported by the
routing cache. If you say Y here, alternative routes are cached
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-10-23 11:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-23 6:59 [PATCH 2.6.19-rc2] [REVISED] net/ipv4/multipath_wrandom.c: check kmalloc() return value Amit Choudhary
2006-10-23 7:46 ` James Morris
2006-10-23 11:17 ` Patrick McHardy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).