lkml.org 
[lkml]   [2018]   [Sep]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.14 005/173] net/mlx5: Check for error in mlx5_attach_interface
    Date
    4.14-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Huy Nguyen <huyn@mellanox.com>

    [ Upstream commit 47bc94b82291e007da61ee1b3d18c77871f3e158 ]

    Currently, mlx5_attach_interface does not check for error
    after calling intf->attach or intf->add. When these two calls
    fails, the client is not initialized and will cause issues such as
    kernel panic on invalid address in the teardown path (mlx5_detach_interface)

    Fixes: 737a234bb638 ("net/mlx5: Introduce attach/detach to interface API")
    Signed-off-by: Huy Nguyen <huyn@mellanox.com>
    Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    drivers/net/ethernet/mellanox/mlx5/core/dev.c | 15 ++++++++++-----
    1 file changed, 10 insertions(+), 5 deletions(-)

    --- a/drivers/net/ethernet/mellanox/mlx5/core/dev.c
    +++ b/drivers/net/ethernet/mellanox/mlx5/core/dev.c
    @@ -132,11 +132,11 @@ void mlx5_add_device(struct mlx5_interfa
    delayed_event_start(priv);

    dev_ctx->context = intf->add(dev);
    - set_bit(MLX5_INTERFACE_ADDED, &dev_ctx->state);
    - if (intf->attach)
    - set_bit(MLX5_INTERFACE_ATTACHED, &dev_ctx->state);
    -
    if (dev_ctx->context) {
    + set_bit(MLX5_INTERFACE_ADDED, &dev_ctx->state);
    + if (intf->attach)
    + set_bit(MLX5_INTERFACE_ATTACHED, &dev_ctx->state);
    +
    spin_lock_irq(&priv->ctx_lock);
    list_add_tail(&dev_ctx->list, &priv->ctx_list);

    @@ -211,12 +211,17 @@ static void mlx5_attach_interface(struct
    if (intf->attach) {
    if (test_bit(MLX5_INTERFACE_ATTACHED, &dev_ctx->state))
    goto out;
    - intf->attach(dev, dev_ctx->context);
    + if (intf->attach(dev, dev_ctx->context))
    + goto out;
    +
    set_bit(MLX5_INTERFACE_ATTACHED, &dev_ctx->state);
    } else {
    if (test_bit(MLX5_INTERFACE_ADDED, &dev_ctx->state))
    goto out;
    dev_ctx->context = intf->add(dev);
    + if (!dev_ctx->context)
    + goto out;
    +
    set_bit(MLX5_INTERFACE_ADDED, &dev_ctx->state);
    }


    \
     
     \ /
      Last update: 2018-09-24 14:57    [W:4.353 / U:0.680 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site