net/mlx5_core: Fix a bug in alloc_token
authorAchiad Shochat <achiad@mellanox.com>
Thu, 2 Apr 2015 14:07:28 +0000 (17:07 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 2 Apr 2015 20:33:42 +0000 (16:33 -0400)
In alloc_token(), the token '1' would be allocated twice consecutively.

Signed-off-by: Achiad Shochat <achiad@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: Eli Cohen <eli@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx5/core/cmd.c

index 0d86269..697d538 100644 (file)
@@ -125,7 +125,10 @@ static u8 alloc_token(struct mlx5_cmd *cmd)
        u8 token;
 
        spin_lock(&cmd->token_lock);
-       token = cmd->token++ % 255 + 1;
+       cmd->token++;
+       if (cmd->token == 0)
+               cmd->token++;
+       token = cmd->token;
        spin_unlock(&cmd->token_lock);
 
        return token;