Re: [Bluez PATCH v3 4/4] shared/mgmt: Fix memory leak in mgmt_tlv_list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Howard,

On Mon, Dec 28, 2020 at 3:34 AM Howard Chung <howardchung@xxxxxxxxxx> wrote:
>
> This patch freed the mgmt_tlv properly in mgmt_tlv_list_free.
>
> Reviewed-by: apusaka@xxxxxxxxxxxx
> Reviewed-by: mcchou@xxxxxxxxxxxx
> ---
>
> (no changes since v2)
>
> Changes in v2:
> - Fix incompatible pointer type error of mgmt_tlv_free
>
>  src/shared/mgmt.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/shared/mgmt.c b/src/shared/mgmt.c
> index dc8107846668..0d0c957709d7 100644
> --- a/src/shared/mgmt.c
> +++ b/src/shared/mgmt.c
> @@ -588,14 +588,15 @@ static struct mgmt_tlv *mgmt_tlv_new(uint16_t type, uint8_t length,
>         return entry;
>  }
>
> -static void mgmt_tlv_free(struct mgmt_tlv *entry)
> +static void mgmt_tlv_free(void *data)
>  {
> +       struct mgmt_tlv *entry = data;
>         free(entry);
>  }
>
>  void mgmt_tlv_list_free(struct mgmt_tlv_list *tlv_list)
>  {
> -       queue_destroy(tlv_list->tlv_queue, NULL);
> +       queue_destroy(tlv_list->tlv_queue, mgmt_tlv_free);

It might be better to just pass free directly instead of mgmt_tlv_free
since all it does currently is call free anyway.

>         free(tlv_list);
>  }
>
> --
> 2.29.2.729.g45daf8777d-goog
>


-- 
Luiz Augusto von Dentz



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux