lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMGffE=EuoiGGmddFawWL1qm9kfqBDB+ttiQuC-sAze0_A+H2Q@mail.gmail.com>
Date:   Thu, 1 Oct 2020 11:45:21 +0200
From:   Jinpu Wang <jinpu.wang@...ud.ionos.com>
To:     Gioh Kim <gi-oh.kim@...ud.ionos.com>
Cc:     Danil Kipnis <danil.kipnis@...ud.ionos.com>,
        linux-kernel@...r.kernel.org, linux-rdma@...r.kernel.org
Subject: Re: [PATCH 2/2] RDMA/rtrs: check before free

On Thu, Oct 1, 2020 at 9:27 AM Gioh Kim <gi-oh.kim@...ud.ionos.com> wrote:
>
> From: Gioh Kim <gi-oh.kim@...ud.ionos.com>
>
> If rtrs_iu_alloc failed to allocate buffer or map dma,
> there are some allocated addresses and some NULL addresses
> in the array. rtrs_iu_free should check data before free.
>
> Signed-off-by: Gioh Kim <gi-oh.kim@...ud.ionos.com>
> ---
>  drivers/infiniband/ulp/rtrs/rtrs.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c
> index 5163e662f86f..ca2d2d3e4192 100644
> --- a/drivers/infiniband/ulp/rtrs/rtrs.c
> +++ b/drivers/infiniband/ulp/rtrs/rtrs.c
> @@ -61,8 +61,12 @@ void rtrs_iu_free(struct rtrs_iu *ius, struct ib_device *ibdev, u32 queue_size)
>
>         for (i = 0; i < queue_size; i++) {
>                 iu = &ius[i];
> -               ib_dma_unmap_single(ibdev, iu->dma_addr, iu->size, iu->direction);
> -               kfree(iu->buf);
> +               if (iu->dma_addr) {
> +                       ib_dma_unmap_single(ibdev, iu->dma_addr, iu->size, iu->direction);
> +               }
No need for bracket
> +               if (iu->buf) {
> +                       kfree(iu->buf);
> +               }
kfree checks NULL already.
>         }
>         kfree(ius);
>  }
> --
> 2.20.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ