net/mlx5_core: Avoid copying outbox in aysnc command completion
authorEli Cohen <eli@dev.mellanox.co.il>
Thu, 2 Apr 2015 14:07:26 +0000 (17:07 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 2 Apr 2015 20:33:41 +0000 (16:33 -0400)
Avoid copying to the output buffer in cmd_exec since this is done after the
command is completed. Failure to do this may cause cases where the callback
handler is called before the copy done by cmd_exec which then overwrites it.

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

index 43a73d36b01d6e5756e76a49b21bbe69ea2a8a26..290ae87fdef7823e9884606a68680f0aa05a3db6 100644 (file)
@@ -1236,7 +1236,8 @@ static int cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out,
                goto out_out;
        }
 
-       err = mlx5_copy_from_msg(out, outb, out_size);
+       if (!callback)
+               err = mlx5_copy_from_msg(out, outb, out_size);
 
 out_out:
        if (!callback)