diff mbox series

[2/2] RDMA/rtrs-clt: Move free_permit from free_clt to rtrs_clt_close

Message ID 20220209151425.142448-2-haris.iqbal@ionos.com (mailing list archive)
State Superseded
Headers show
Series [v3,1/2] RDMA/rtrs-clt: Fix possible double free in error case | expand

Commit Message

Haris Iqbal Feb. 9, 2022, 3:14 p.m. UTC
Error path of rtrs_clt_open calls free_clt, where free_permit is called.
This is wrong since error path of rtrs_clt_open does not need to call
free_permit.

Also, moving free_permits call to rtrs_clt_close, makes it more aligned
with the call to alloc_permit in rtrs_clt_open.

Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com>
---
 drivers/infiniband/ulp/rtrs/rtrs-clt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jinpu Wang Feb. 9, 2022, 6:06 p.m. UTC | #1
On Wed, Feb 9, 2022 at 4:14 PM Md Haris Iqbal <haris.iqbal@ionos.com> wrote:
>
> Error path of rtrs_clt_open calls free_clt, where free_permit is called.
> This is wrong since error path of rtrs_clt_open does not need to call
> free_permit.
>
> Also, moving free_permits call to rtrs_clt_close, makes it more aligned
> with the call to alloc_permit in rtrs_clt_open.
>
> Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com>
Reviewed-by: Jack Wang <jinpu.wang@ionos.com>
Thx!
> ---
>  drivers/infiniband/ulp/rtrs/rtrs-clt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> index d20bad345eff..c2c860d0c56e 100644
> --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> @@ -2774,7 +2774,6 @@ static struct rtrs_clt_sess *alloc_clt(const char *sessname, size_t paths_num,
>
>  static void free_clt(struct rtrs_clt_sess *clt)
>  {
> -       free_permits(clt);
>         free_percpu(clt->pcpu_path);
>
>         /*
> @@ -2896,6 +2895,7 @@ void rtrs_clt_close(struct rtrs_clt_sess *clt)
>                 rtrs_clt_destroy_path_files(clt_path, NULL);
>                 kobject_put(&clt_path->kobj);
>         }
> +       free_permits(clt);
>         free_clt(clt);
>  }
>  EXPORT_SYMBOL(rtrs_clt_close);
> --
> 2.25.1
>
diff mbox series

Patch

diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
index d20bad345eff..c2c860d0c56e 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
@@ -2774,7 +2774,6 @@  static struct rtrs_clt_sess *alloc_clt(const char *sessname, size_t paths_num,
 
 static void free_clt(struct rtrs_clt_sess *clt)
 {
-	free_permits(clt);
 	free_percpu(clt->pcpu_path);
 
 	/*
@@ -2896,6 +2895,7 @@  void rtrs_clt_close(struct rtrs_clt_sess *clt)
 		rtrs_clt_destroy_path_files(clt_path, NULL);
 		kobject_put(&clt_path->kobj);
 	}
+	free_permits(clt);
 	free_clt(clt);
 }
 EXPORT_SYMBOL(rtrs_clt_close);