From: Moshe Shemesh <moshes20.il@gmail.com>
To: Wenwen Wang <wenwen@cs.uga.edu>
Cc: Saeed Mahameed <saeedm@mellanox.com>,
Leon Romanovsky <leon@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
"open list:MELLANOX MLX5 core VPI driver"
<netdev@vger.kernel.org>,
"open list:MELLANOX MLX5 core VPI driver"
<linux-rdma@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] net/mlx5: Fix a memory leak bug
Date: Mon, 19 Aug 2019 16:00:53 +0300 [thread overview]
Message-ID: <CALBF4T_xmmAyTpPRfuC0a_C+TpX5xbA9+U1JxUJ6p1RvUFjGHQ@mail.gmail.com> (raw)
In-Reply-To: <1565684495-2454-1-git-send-email-wenwen@cs.uga.edu>
Please don't change that.
On command timeout we don't release ent, since the FW event on
completion can occur after timeout, so it is released on the
completion handler mlx5_cmd_comp_handler().
See commit 73dd3a4839c1d ("net/mlx5: Avoid using pending command
interface slots").
On Tue, Aug 13, 2019 at 11:22 AM Wenwen Wang <wenwen@cs.uga.edu> wrote:
>
> In mlx5_cmd_invoke(), 'ent' is allocated through kzalloc() in alloc_cmd().
> After the work is queued, wait_func() is invoked to wait the completion of
> the work. If wait_func() returns -ETIMEDOUT, the following execution will
> be terminated. However, the allocated 'ent' is not deallocated on this
> program path, leading to a memory leak bug.
>
> To fix the above issue, free 'ent' before returning the error.
>
> Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
> ---
> drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
> index 8cdd7e6..90cdb9a 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
> @@ -1036,7 +1036,7 @@ static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in,
>
> err = wait_func(dev, ent);
> if (err == -ETIMEDOUT)
> - goto out;
> + goto out_free;
>
> ds = ent->ts2 - ent->ts1;
> op = MLX5_GET(mbox_in, in->first.data, opcode);
> --
> 2.7.4
>
next prev parent reply other threads:[~2019-08-19 13:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-13 8:21 [PATCH] net/mlx5: Fix a memory leak bug Wenwen Wang
2019-08-19 13:00 ` Moshe Shemesh [this message]
2019-08-20 21:00 ` Saeed Mahameed
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=CALBF4T_xmmAyTpPRfuC0a_C+TpX5xbA9+U1JxUJ6p1RvUFjGHQ@mail.gmail.com \
--to=moshes20.il@gmail.com \
--cc=davem@davemloft.net \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=saeedm@mellanox.com \
--cc=wenwen@cs.uga.edu \
/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).