From: Johan Hedberg <johan.hedberg@gmail.com>
To: Anderson Lizardo <anderson.lizardo@openbossa.org>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH v2] Fix leak of EIR data if RSSI does not change
Date: Mon, 27 Dec 2010 23:48:41 +0200 [thread overview]
Message-ID: <20101227214841.GA22777@jh-x301> (raw)
In-Reply-To: <1293473827-26418-1-git-send-email-anderson.lizardo@openbossa.org>
Hi Lizardo,
On Mon, Dec 27, 2010, Anderson Lizardo wrote:
> If RSSI value does not change, memory used by parsed EIR data would leak
> because it would not be assigned to the remote_dev_info structure.
>
> Also simplify related code and replace a couple of g_free()'s with
> free() (simply because they were allocated with malloc()).
Beware of words like "also" and "and" in commit messages. Often they are
a good indication that the patch shold be split into multiple ones.
Though in this case I can't really make up my mind if it's fine since
the changes are so strongly related. I'll leave it up to you to think
about it and decide if you can cleanly split this into two patches or
not.
> @@ -529,6 +537,14 @@ void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint32_t class,
> else
> name_status = NAME_NOT_REQUIRED;
>
> + /* Update storage if EIR contains the complete device name */
> + if (eir_data.name && eir_data.name_complete) {
> + write_device_name(local, peer, eir_data.name);
> + name_status = NAME_NOT_REQUIRED;
> + g_free(eir_data.name);
> + eir_data.name = NULL;
> + }
> +
> create_name(filename, PATH_MAX, STORAGEDIR, local_addr, "aliases");
> alias = textfile_get(filename, peer_addr);
>
> @@ -547,28 +563,13 @@ void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint32_t class,
> } else
> legacy = TRUE;
>
> - if (eir_data.name) {
> - if (eir_data.name_complete) {
> - write_device_name(local, peer, eir_data.name);
> - name_status = NAME_NOT_REQUIRED;
> -
> - if (name)
> - g_free(name);
> -
> - name = eir_data.name;
> - } else {
> - if (name)
> - free(eir_data.name);
> - else
> - name = eir_data.name;
> - }
> - }
> -
> - adapter_update_found_devices(adapter, peer, rssi, class, name, alias,
> - legacy, eir_data.services, name_status);
> + if (!adapter_update_found_devices(adapter, peer, rssi, class, name,
> + alias, legacy, eir_data.services,
> + name_status))
> + free_eir_data(&eir_data);
>
> - g_free(name);
> - g_free(alias);
> + free(name);
> + free(alias);
> }
>
> void btd_event_set_legacy_pairing(bdaddr_t *local, bdaddr_t *peer,
It looks to me like shortened names are completely ignored after this
patch, even to the extent that if there's a shortened name the memory
will be leaked if adapter_update_found_devices returns TRUE.
If we don't have any name in storage and all we have is a shortened name
then I think it should be included in the DeviceFound signal (which is
what the existing code does).
Johan
next prev parent reply other threads:[~2010-12-27 21:48 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-27 13:21 [PATCH 1/4] Remove ancient NAME_SENT name resolution status Anderson Lizardo
2010-12-27 13:21 ` [PATCH 2/4] Use stored device name (if any) instead of EIR data Anderson Lizardo
2010-12-27 14:14 ` Luiz Augusto von Dentz
2010-12-27 14:35 ` Anderson Lizardo
2010-12-27 14:53 ` Johan Hedberg
2010-12-27 15:33 ` Anderson Lizardo
2010-12-27 15:21 ` Anderson Lizardo
2010-12-27 18:20 ` Anderson Lizardo
2010-12-27 13:21 ` [PATCH 3/4] Remove outdated comments Anderson Lizardo
2010-12-27 15:09 ` Johan Hedberg
2010-12-27 13:21 ` [PATCH 4/4] Fix leak of EIR data if RSSI does not change Anderson Lizardo
2010-12-27 15:11 ` Johan Hedberg
2010-12-27 18:23 ` Anderson Lizardo
2010-12-27 18:17 ` [PATCH v2] " Anderson Lizardo
2010-12-27 21:48 ` Johan Hedberg [this message]
2010-12-27 22:24 ` Anderson Lizardo
2010-12-28 18:16 ` Anderson Lizardo
2010-12-28 18:10 ` [PATCH v3] " Anderson Lizardo
2010-12-28 18:49 ` Johan Hedberg
2010-12-27 15:08 ` [PATCH 1/4] Remove ancient NAME_SENT name resolution status Johan Hedberg
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=20101227214841.GA22777@jh-x301 \
--to=johan.hedberg@gmail.com \
--cc=anderson.lizardo@openbossa.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox