diff mbox

[rdma-core] mlx5: Fix device context allocation

Message ID 1490618609-16931-1-git-send-email-yishaih@mellanox.com (mailing list archive)
State Accepted
Headers show

Commit Message

Yishai Hadas March 27, 2017, 12:43 p.m. UTC
From: Artemy Kovalyov <artemyko@mellanox.com>

Use calloc to allocate device context so the unset bytes are zero.
When building a *non* release mode (i.e. without DCMAKE_BUILD_TYPE=Release)
the below assert is applicable and might raise:
assert(dev->_ops._dummy1).

Fix below commit to use calloc instead of malloc for mlx5 as well.

Fixes: 85c449528709 ("providers: Make every provider allocate a
verbs_device")
Signed-off-by: Artemy Kovalyov <artemyko@mellanox.com>
Reviewed-by: Yishai Hadas <yishaih@mellanox.com>
---

Pull request was sent:
https://github.com/linux-rdma/rdma-core/pull/109

 providers/mlx5/mlx5.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Yishai Hadas March 28, 2017, 7:47 a.m. UTC | #1
On 3/27/2017 3:43 PM, Yishai Hadas wrote:
> From: Artemy Kovalyov <artemyko@mellanox.com>
>
> Use calloc to allocate device context so the unset bytes are zero.
> When building a *non* release mode (i.e. without DCMAKE_BUILD_TYPE=Release)
> the below assert is applicable and might raise:
> assert(dev->_ops._dummy1).
>
> Fix below commit to use calloc instead of malloc for mlx5 as well.
>
> Fixes: 85c449528709 ("providers: Make every provider allocate a
> verbs_device")
> Signed-off-by: Artemy Kovalyov <artemyko@mellanox.com>
> Reviewed-by: Yishai Hadas <yishaih@mellanox.com>
> ---
>
> Pull request was sent:
> https://github.com/linux-rdma/rdma-core/pull/109
>
>  providers/mlx5/mlx5.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/providers/mlx5/mlx5.c b/providers/mlx5/mlx5.c
> index edb6d35..30f165b 100644
> --- a/providers/mlx5/mlx5.c
> +++ b/providers/mlx5/mlx5.c
> @@ -1006,7 +1006,7 @@ found:
>  		return NULL;
>  	}
>
> -	dev = malloc(sizeof *dev);
> +	dev = calloc(1, sizeof *dev);
>  	if (!dev) {
>  		fprintf(stderr, PFX "Fatal: couldn't allocate device for %s\n",
>  			uverbs_sys_path);
>

Merged.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/providers/mlx5/mlx5.c b/providers/mlx5/mlx5.c
index edb6d35..30f165b 100644
--- a/providers/mlx5/mlx5.c
+++ b/providers/mlx5/mlx5.c
@@ -1006,7 +1006,7 @@  found:
 		return NULL;
 	}
 
-	dev = malloc(sizeof *dev);
+	dev = calloc(1, sizeof *dev);
 	if (!dev) {
 		fprintf(stderr, PFX "Fatal: couldn't allocate device for %s\n",
 			uverbs_sys_path);