public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Guoqing Jiang <guoqing.jiang@linux.dev>
To: Li Zhijian <lizhijian@fujitsu.com>,
	haris.iqbal@ionos.com, jinpu.wang@ionos.com, jgg@ziepe.ca,
	leon@kernel.org, linux-rdma@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH for-next v2 2/3] RDMA/rtrs: Fix the last iu->buf leak in err path
Date: Sun, 23 Apr 2023 10:56:30 +0800	[thread overview]
Message-ID: <58a984d3-a89d-89d4-2491-a559bc8b1076@linux.dev> (raw)
In-Reply-To: <1682213212-2-3-git-send-email-lizhijian@fujitsu.com>



On 4/23/23 09:26, Li Zhijian wrote:
> The last iu->buf will leak if ib_dma_mapping_error() fails.

Fixes: c0894b3ea69d("RDMA/rtrs: core: lib functions shared between 
client and server modules")

> Signed-off-by: Li Zhijian<lizhijian@fujitsu.com>
> ---
> V2: new patch to address memory leaking
> ---
>   drivers/infiniband/ulp/rtrs/rtrs.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c
> index 4bf9d868cc52..3696f367ff51 100644
> --- a/drivers/infiniband/ulp/rtrs/rtrs.c
> +++ b/drivers/infiniband/ulp/rtrs/rtrs.c
> @@ -37,8 +37,10 @@ struct rtrs_iu *rtrs_iu_alloc(u32 iu_num, size_t size, gfp_t gfp_mask,
>   			goto err;
>   
>   		iu->dma_addr = ib_dma_map_single(dma_dev, iu->buf, size, dir);
> -		if (ib_dma_mapping_error(dma_dev, iu->dma_addr))
> +		if (ib_dma_mapping_error(dma_dev, iu->dma_addr)) {
> +			kfree(iu->buf);
>   			goto err;
> +		}
>   
>   		iu->cqe.done  = done;
>   		iu->size      = size;

Good catch, Acked-by: Guoqing Jiang <guoqing.jiang@linux.dev>

Thanks,
Guoqing

  reply	other threads:[~2023-04-23  2:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-23  1:26 [PATCH for-next v2 0/3] RDMA/rtrs: bugfix and cleanups Li Zhijian
2023-04-23  1:26 ` [PATCH for-next v2 1/3] RDMA/rtrs: remove duplicate cq_num assignment Li Zhijian
2023-04-23  1:26 ` [PATCH for-next v2 2/3] RDMA/rtrs: Fix the last iu->buf leak in err path Li Zhijian
2023-04-23  2:56   ` Guoqing Jiang [this message]
2023-04-24  5:18   ` Jinpu Wang
2023-04-23  1:26 ` [PATCH for-next v2 3/3] RDMA/rtrs: Fix rxe_dealloc_pd warning Li Zhijian
2023-04-23  3:08   ` Guoqing Jiang
2023-04-23  7:29     ` Zhijian Li (Fujitsu)
2023-04-24  4:33       ` Jinpu Wang
2023-04-25  6:10         ` Guoqing Jiang
2023-04-24  4:32   ` Jinpu Wang
2023-04-25  1:03 ` [PATCH for-next v2 0/3] RDMA/rtrs: bugfix and cleanups Zhijian Li (Fujitsu)

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=58a984d3-a89d-89d4-2491-a559bc8b1076@linux.dev \
    --to=guoqing.jiang@linux.dev \
    --cc=haris.iqbal@ionos.com \
    --cc=jgg@ziepe.ca \
    --cc=jinpu.wang@ionos.com \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=lizhijian@fujitsu.com \
    /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