Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1535601

Re: [PATCH 1/1] infiniband: hw: mlx4: fix improper return value

From Leon Romanovsky <leon@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH 1/1] infiniband: hw: mlx4: fix improper return value
Date 2016-12-04 07:20 +0100
Message-ID <sKyjv-3Ap-1@gated-at.bofh.it> (permalink)
References <sKxQt-38Y-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On Sun, Dec 04, 2016 at 01:49:04PM +0800, Pan Bian wrote:
> From: Pan Bian <bianpan2016@163.com>
>
> If uhw->inlen is non-zero, the value of variable err is 0 if the copy
> succeeds. Then, if kzalloc() or kmalloc() returns a NULL pointer, it
> will return 0 to the callers. As a result, the callers cannot detect the
> errors. This patch fixes the bug, assigning "-ENOMEM" to err before
> the NULL pointer checks.
>
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=189031
>
> Signed-off-by: Pan Bian <bianpan2016@163.com>
> ---
>  drivers/infiniband/hw/mlx4/main.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index b597e82..f6c5158 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -455,6 +455,7 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
>  		sizeof(resp.response_length);
>  	in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
>  	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
> +	err = -ENOMEM;
>  	if (!in_mad || !out_mad)
>  		goto out;

In such case, the err initialization at the beginning of
mlx4_ib_query_device function is not necessary. Can you please remove it?

Besides that, look good.
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>

>
> --
> 1.9.1
>
>
> --
> 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

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 1/1] infiniband: hw: mlx4: fix improper return value Pan Bian <bianpan201603@163.com> - 2016-12-04 06:50 +0100
  Re: [PATCH 1/1] infiniband: hw: mlx4: fix improper return value Leon Romanovsky <leon@kernel.org> - 2016-12-04 07:20 +0100

csiph-web