From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by dpdk.org (Postfix) with ESMTP id CC64F2C6E for ; Thu, 24 May 2018 16:37:04 +0200 (CEST) Received: by mail-wr0-f196.google.com with SMTP id i14-v6so3577284wre.2 for ; Thu, 24 May 2018 07:37:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=0EeahbJuEe5M3kynwq82tXqKkuGuvZS4Ri/wyAmeYBQ=; b=V+DNioDxilYtHSUso/AGNHoZfNBr1rNIN+VvsI0Q/JXRy84sHfS/ZmAfNK7OsApzhE E9oS3JDjDP45qWpuofzo9yLbcYAttdvUNQEsGIeooqCjU/C5OPujonuRDKWxg+uwAC9l vtowxDr+hz66MA/vHfaLSHWUF0x7DMcxJTUc/ciXYsKNnmXZXkRWhvLgK3+ZXmofgWlq 2PHBb92ie8Gq1twoRp7v6RUaE2p2L4iHCbBos1cKkwFvYY+JTYO6BZbhKu91QOVr+XSK AL5vR9LG1DJ0aklKU5d/j2h0KFR5ptkF3m1nunC1ZA2mVVfWByEUJ5YoUyXbT8fUtgjP Q4AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=0EeahbJuEe5M3kynwq82tXqKkuGuvZS4Ri/wyAmeYBQ=; b=r/KHdoBzOmVky2D0N6XYlF7y+ypD/MIMA5Bxn8pV6uyKoFSLmvCacFHg+cJTiVSG9H tQoVIkZSC/qnGlNBfCO1cbYypSezd4q1H8S8P7fBK//i8nuvZT0NDHoUtoZfXYVGTLRP s+yOQ/XAnHW0sN5coqzusdDzqkdZUhgudjWjSLLUbAe6OXmjflt5chTsUhI83SqT941J WZ7FUv3jDzowS8MjkcYc+10KWQJOtLR3KXfogYjKdJXUTg4BsWgLzj14pWv7KYuuedul ZLubJEZ7jC88E4OsWO4q4YeTIDeJQcbpk/msNVthZ9OxAAxkR9D8P4E1Z7rZO+Vbv27f e9yg== X-Gm-Message-State: ALKqPwc56Ke0OhiesZXzGmiYXjIZN7RVI2X8HEKWWH5l6G6HL0RSHUcL YZK5Zw3bPJ+DRhu6Dk1UnA2X9Q== X-Google-Smtp-Source: AB8JxZpLYwg5Jns9M76amd8V8q5Z5JK8Zxu6I++Y/cfPYAFaJPCC0+Ai90B1iQO7aVvE73nCW5Wuqg== X-Received: by 2002:adf:9ae5:: with SMTP id a92-v6mr6127657wrc.180.1527172624630; Thu, 24 May 2018 07:37:04 -0700 (PDT) Received: from 6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id j76-v6sm16147138wmf.33.2018.05.24.07.37.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 07:37:03 -0700 (PDT) Date: Thu, 24 May 2018 16:36:49 +0200 From: Adrien Mazarguil To: Shahaf Shuler Cc: dev@dpdk.org, Yongseok Koh Message-ID: <20180524143535.29996-1-adrien.mazarguil@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Mailer: git-send-email 2.11.0 Subject: [dpdk-dev] [PATCH] net/mlx5: fix crash when configure is not called X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 May 2018 14:37:05 -0000 Although uncommon, applications may destroy a device immediately after probing it without going through dev_configure() first. This patch addresses a crash which occurs when mlx5_dev_close() calls mlx5_mr_release() due to an uninitialized entry in the private structure. Fixes: 974f1e7ef146 ("net/mlx5: add new memory region support") Cc: Yongseok Koh Signed-off-by: Adrien Mazarguil --- drivers/net/mlx5/mlx5.c | 7 +++++++ drivers/net/mlx5/mlx5_ethdev.c | 4 ---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 36d72f757..11b395b64 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include "mlx5.h" #include "mlx5_utils.h" @@ -1145,6 +1147,11 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, goto port_error; } priv->config.max_verbs_prio = verb_priorities; + /* Add device to memory callback list. */ + rte_rwlock_write_lock(&mlx5_shared_data->mem_event_rwlock); + LIST_INSERT_HEAD(&mlx5_shared_data->mem_event_cb_list, + priv, mem_event_cb); + rte_rwlock_write_unlock(&mlx5_shared_data->mem_event_rwlock); rte_eth_dev_probing_finish(eth_dev); continue; port_error: diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c index c52ec6fb7..f6cebae41 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -403,10 +403,6 @@ mlx5_dev_configure(struct rte_eth_dev *dev) /* rte_errno is already set. */ return -rte_errno; } - rte_rwlock_write_lock(&mlx5_shared_data->mem_event_rwlock); - LIST_INSERT_HEAD(&mlx5_shared_data->mem_event_cb_list, - priv, mem_event_cb); - rte_rwlock_write_unlock(&mlx5_shared_data->mem_event_rwlock); return 0; } -- 2.11.0