linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] IB/mlx5: fix debugfs cleanup
@ 2017-09-18 11:28 Sudip Mukherjee
  2017-09-18 11:49 ` Leon Romanovsky
  2017-09-22 17:18 ` Doug Ledford
  0 siblings, 2 replies; 3+ messages in thread
From: Sudip Mukherjee @ 2017-09-18 11:28 UTC (permalink / raw)
  To: Matan Barak, Leon Romanovsky, Doug Ledford, Sean Hefty, Hal Rosenstock
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, Sudip Mukherjee

From: Sudip Mukherjee <sudipm.mukherjee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

If delay_drop_debugfs_init() fails in any of the operations to create
debugfs, it is calling delay_drop_debugfs_cleanup() as part of its
cleanup. But delay_drop_debugfs_cleanup() checks for 'dbg' and since
we have not yet pointed 'dbg' to the debugfs we need to cleanup, the
cleanup fails and we are left with stray debugfs elements and also a
memory leak.

Fixes: 4a5fd5d2965c ("IB/mlx5: Add necessary delay drop assignment")
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/infiniband/hw/mlx5/main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index ab3c562..05fb4bd 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -3837,11 +3837,13 @@ static int delay_drop_debugfs_init(struct mlx5_ib_dev *dev)
 	if (!dbg)
 		return -ENOMEM;
 
+	dev->delay_drop.dbg = dbg;
+
 	dbg->dir_debugfs =
 		debugfs_create_dir("delay_drop",
 				   dev->mdev->priv.dbg_root);
 	if (!dbg->dir_debugfs)
-		return -ENOMEM;
+		goto out_debugfs;
 
 	dbg->events_cnt_debugfs =
 		debugfs_create_atomic_t("num_timeout_events", 0400,
@@ -3865,8 +3867,6 @@ static int delay_drop_debugfs_init(struct mlx5_ib_dev *dev)
 	if (!dbg->timeout_debugfs)
 		goto out_debugfs;
 
-	dev->delay_drop.dbg = dbg;
-
 	return 0;
 
 out_debugfs:
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] IB/mlx5: fix debugfs cleanup
  2017-09-18 11:28 [PATCH v2] IB/mlx5: fix debugfs cleanup Sudip Mukherjee
@ 2017-09-18 11:49 ` Leon Romanovsky
  2017-09-22 17:18 ` Doug Ledford
  1 sibling, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2017-09-18 11:49 UTC (permalink / raw)
  To: Sudip Mukherjee
  Cc: Matan Barak, Doug Ledford, Sean Hefty, Hal Rosenstock,
	linux-kernel, linux-rdma

[-- Attachment #1: Type: text/plain, Size: 1318 bytes --]

On Mon, Sep 18, 2017 at 12:28:48PM +0100, Sudip Mukherjee wrote:
> From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
>
> If delay_drop_debugfs_init() fails in any of the operations to create
> debugfs, it is calling delay_drop_debugfs_cleanup() as part of its
> cleanup. But delay_drop_debugfs_cleanup() checks for 'dbg' and since
> we have not yet pointed 'dbg' to the debugfs we need to cleanup, the
> cleanup fails and we are left with stray debugfs elements and also a
> memory leak.
>
> Fixes: 4a5fd5d2965c ("IB/mlx5: Add necessary delay drop assignment")
> Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
> ---
>  drivers/infiniband/hw/mlx5/main.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
> index ab3c562..05fb4bd 100644
> --- a/drivers/infiniband/hw/mlx5/main.c
> +++ b/drivers/infiniband/hw/mlx5/main.c
> @@ -3837,11 +3837,13 @@ static int delay_drop_debugfs_init(struct mlx5_ib_dev *dev)
>  	if (!dbg)
>  		return -ENOMEM;
>
> +	dev->delay_drop.dbg = dbg;
> +
>  	dbg->dir_debugfs =
>  		debugfs_create_dir("delay_drop",
>  				   dev->mdev->priv.dbg_root);
>  	if (!dbg->dir_debugfs)
> -		return -ENOMEM;
> +		goto out_debugfs;
>

Thanks,
Acked-by: Leon Romanovsky <leonro@mellanox.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] IB/mlx5: fix debugfs cleanup
  2017-09-18 11:28 [PATCH v2] IB/mlx5: fix debugfs cleanup Sudip Mukherjee
  2017-09-18 11:49 ` Leon Romanovsky
@ 2017-09-22 17:18 ` Doug Ledford
  1 sibling, 0 replies; 3+ messages in thread
From: Doug Ledford @ 2017-09-22 17:18 UTC (permalink / raw)
  To: Sudip Mukherjee, Matan Barak, Leon Romanovsky, Sean Hefty,
	Hal Rosenstock
  Cc: linux-kernel, linux-rdma

On Mon, 2017-09-18 at 12:28 +0100, Sudip Mukherjee wrote:
> From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
> 
> If delay_drop_debugfs_init() fails in any of the operations to create
> debugfs, it is calling delay_drop_debugfs_cleanup() as part of its
> cleanup. But delay_drop_debugfs_cleanup() checks for 'dbg' and since
> we have not yet pointed 'dbg' to the debugfs we need to cleanup, the
> cleanup fails and we are left with stray debugfs elements and also a
> memory leak.
> 
> Fixes: 4a5fd5d2965c ("IB/mlx5: Add necessary delay drop assignment")
> Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>

Thanks, applied to rc.

-- 
Doug Ledford <dledford@redhat.com>
    GPG KeyID: B826A3330E572FDD
    Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-09-22 17:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-18 11:28 [PATCH v2] IB/mlx5: fix debugfs cleanup Sudip Mukherjee
2017-09-18 11:49 ` Leon Romanovsky
2017-09-22 17:18 ` Doug Ledford

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).