All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: chengbo <515672508@qq.com>
Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCH BlueZ 1/1] scr:Set property mode failed,memory leak
Date: Mon, 17 Aug 2020 10:32:29 -0700	[thread overview]
Message-ID: <CABBYNZ+-zF9qLrYdBSWjdWd3qfOJOk-VzNVfTG5eSLYPZ76ahw@mail.gmail.com> (raw)
In-Reply-To: <20200817024234.13758-1-515672508@qq.com>

Hi Chengbo,

On Sun, Aug 16, 2020 at 7:57 PM chengbo <515672508@qq.com> wrote:
>
> This patch will fix a memory leak,when set property mode,
> it will creat a request,if failed,the data's memory do not free
> ---
>  src/adapter.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/adapter.c b/src/adapter.c
> index 5e896a9f0..3d07921a7 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -2917,9 +2917,10 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting,
>         data->id = id;
>
>         if (mgmt_send(adapter->mgmt, opcode, adapter->dev_id, len, param,
> -                       property_set_mode_complete, data, g_free) > 0)
> +                       property_set_mode_complete, data, g_free) > 0) {
> +               g_free(data);
>                 return;
> -
> +       }

This is actually the other way around, if it fails then 0 is returned
and g_free is called, so this would cause a double free as g_free
would be called on destroy.

>         g_free(data);
>
>  failed:
> --
> 2.20.1
>
>
>


-- 
Luiz Augusto von Dentz

  reply	other threads:[~2020-08-17 17:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-17  2:42 [PATCH BlueZ 1/1] scr:Set property mode failed,memory leak chengbo
2020-08-17 17:32 ` Luiz Augusto von Dentz [this message]
2020-08-18  1:24   ` [PATCH] " chengbo
2020-08-18  4:45     ` Luiz Augusto von Dentz

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=CABBYNZ+-zF9qLrYdBSWjdWd3qfOJOk-VzNVfTG5eSLYPZ76ahw@mail.gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=515672508@qq.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.