Re: [B.A.T.M.A.N.] [PATCHv2 1/2] batman-adv: Only set hash class after hash is initialized

Antonio Quartulli
2012-05-05T14:49:41Z

[-- Attachment #1: Type: text/plain, Size: 1065 bytes --]

On Sat, May 05, 2012 at 01:27:27 +0200, Sven Eckelmann wrote:
> We must be sure that there was no error during the creation of the hash before
> we can set the hash lock class. The class set function was added to the wrong
> place in 2c9aa3b4c37bd55148f5f25212c89e7bf5f28497
>
> Signed-off-by: Sven Eckelmann <sven@narfation.org>
> ---
> bridge_loop_avoidance.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c
> index 8bb274b..48831c2 100644
> --- a/bridge_loop_avoidance.c
> +++ b/bridge_loop_avoidance.c
> @@ -1169,13 +1169,13 @@ int bla_init(struct bat_priv *bat_priv)
> bat_priv->claim_hash = hash_new(128);
> bat_priv->backbone_hash = hash_new(32);
>
> + if (!bat_priv->claim_hash || !bat_priv->backbone_hash)
> + return -1;
> +

if one hash_new succeeds and and the other fails, should we free the allocated
structure before returning?

Cheers,

--
Antonio Quartulli

..each of us alone is worth nothing..
Ernesto "Che" Guevara

[-- Attachment #2: Type: application/pgp-signature, Size: 490 bytes --]