From: "Michael S. Tsirkin" <mst@redhat.com>
To: Eli Cohen <elic@nvidia.com>
Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org
Subject: Re: [PATCH 2/2] vdpa/mlx5: Fix possible failure in umem size calculation
Date: Sun, 30 May 2021 04:05:57 -0400 [thread overview]
Message-ID: <20210530040523-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20210530063214.183335-1-elic@nvidia.com>
On Sun, May 30, 2021 at 09:32:14AM +0300, Eli Cohen wrote:
> umem size is a 32 bit unsigned value so assigning it to an int could
> cause false failures. Set the calculated value inside the function and
> modify function name to reflect the fact it updates the size.
>
> Fixes: 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices")
> Signed-off-by: Eli Cohen <elic@nvidia.com>
could you clarify the impact of the bug please?
> ---
> drivers/vdpa/mlx5/net/mlx5_vnet.c | 15 +++++----------
> 1 file changed, 5 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> index 53312f0460ad..fdf3e74bffbd 100644
> --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
> +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> @@ -610,8 +610,8 @@ static void cq_destroy(struct mlx5_vdpa_net *ndev, u16 idx)
> mlx5_db_free(ndev->mvdev.mdev, &vcq->db);
> }
>
> -static int umem_size(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq, int num,
> - struct mlx5_vdpa_umem **umemp)
> +static void set_umem_size(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq, int num,
> + struct mlx5_vdpa_umem **umemp)
> {
> struct mlx5_core_dev *mdev = ndev->mvdev.mdev;
> int p_a;
> @@ -634,7 +634,7 @@ static int umem_size(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq
> *umemp = &mvq->umem3;
> break;
> }
> - return p_a * mvq->num_ent + p_b;
> + (*umemp)->size = p_a * mvq->num_ent + p_b;
> }
>
> static void umem_frag_buf_free(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_umem *umem)
> @@ -650,15 +650,10 @@ static int create_umem(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *m
> void *in;
> int err;
> __be64 *pas;
> - int size;
> struct mlx5_vdpa_umem *umem;
>
> - size = umem_size(ndev, mvq, num, &umem);
> - if (size < 0)
> - return size;
> -
> - umem->size = size;
> - err = umem_frag_buf_alloc(ndev, umem, size);
> + set_umem_size(ndev, mvq, num, &umem);
> + err = umem_frag_buf_alloc(ndev, umem, umem->size);
> if (err)
> return err;
>
> --
> 2.31.1
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
next parent reply other threads:[~2021-05-30 8:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210530063214.183335-1-elic@nvidia.com>
2021-05-30 8:05 ` Michael S. Tsirkin [this message]
[not found] ` <20210530081721.GB119906@mtl-vdi-166.wap.labs.mlnx>
2021-05-30 8:21 ` [PATCH 2/2] vdpa/mlx5: Fix possible failure in umem size calculation Michael S. Tsirkin
[not found] ` <20210530082748.GB120333@mtl-vdi-166.wap.labs.mlnx>
2021-05-30 8:36 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210530040523-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=elic@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).