* [PATCH v2 1/8] doc: Add valgrind.suppressions
From: Szymon Janc @ 2012-11-30 12:57 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
Shamelessly copied from connman.
---
doc/valgrind.suppressions | 236 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 236 insertions(+)
create mode 100644 doc/valgrind.suppressions
diff --git a/doc/valgrind.suppressions b/doc/valgrind.suppressions
new file mode 100644
index 0000000..5967a15
--- /dev/null
+++ b/doc/valgrind.suppressions
@@ -0,0 +1,236 @@
+{
+ <syslog error>
+ Memcheck:Cond
+ obj:/lib/libc-*.so
+ ...
+ fun:localtime_r
+ fun:__vsyslog_chk
+ fun:__syslog_chk
+ fun:__connman_log_init
+ ...
+}
+{
+ <iconv open>
+ Memcheck:Addr4
+ obj:/lib/libc-*.so
+ obj:/lib/libglib-2.0.so*
+ fun:g_iconv_open
+ ...
+ fun:g_convert
+ fun:g_locale_to_utf8
+ fun:g_strerror
+ fun:g_key_file_load_from_file
+ ...
+}
+{
+ <ioctl ADDRT/DELRT>
+ Memcheck:Param
+ ioctl(SIOCADDRT/DELRT)
+ obj:/lib/ld-*.so
+ ...
+}
+{
+ <g_main_loop>
+ Memcheck:Leak
+ fun:memalign
+ ...
+ fun:g_slice_alloc
+ ...
+ fun:g_main_loop_new
+ ...
+}
+{
+ <g_option_context_parse>
+ Memcheck:Leak
+ ...
+ fun:g_slice_alloc
+ ...
+ fun:g_option_context_parse
+ ...
+}
+{
+ <g_key_file_load_from_data>
+ Memcheck:Leak
+ ...
+ fun:g_slice_alloc
+ ...
+ fun:g_key_file_load_from_data
+ ...
+}
+{
+ <g_key_file_new 1>
+ Memcheck:Leak
+ ...
+ fun:g_slice_alloc
+ ...
+ fun:g_key_file_new
+ ...
+}
+{
+ <g_key_file_new 2>
+ Memcheck:Leak
+ fun:*alloc
+ ...
+ fun:g_key_file_new
+ fun:main
+}
+{
+ <connman plugin cleanup>
+ Memcheck:Leak
+ ...
+ fun:__connman_plugin_cleanup
+ ...
+}
+{
+ <cmd line option parsing>
+ Memcheck:Leak
+ fun:malloc
+ fun:g_malloc
+ fun:g_strdup
+ fun:g_set_prgname
+ fun:g_option_context_parse
+ fun:main
+}
+{
+ <dbus system bus setup 1>
+ Memcheck:Leak
+ ...
+ fun:dbus_malloc*
+ ...
+ fun:g_dbus_setup_bus
+ fun:main
+}
+{
+ <dbus system bus setup 2>
+ Memcheck:Leak
+ ...
+ fun:g_malloc*
+ ...
+ fun:dbus_connection_set_watch_functions
+ fun:setup_bus
+ ...
+}
+{
+ <key file get charset>
+ Memcheck:Leak
+ ...
+ fun:g_*alloc*
+ ...
+ fun:g_strerror
+ fun:g_key_file_load_from_file
+ fun:main
+}
+{
+ <dbus disconnect func set>
+ Memcheck:Leak
+ ...
+ fun:filter_data_get
+ fun:g_dbus_add_signal_watch
+ fun:g_dbus_set_disconnect_function
+ fun:main
+}
+{
+ <plugin dlopen>
+ Memcheck:Leak
+ ...
+ fun:dlopen
+ fun:__connman_plugin_init
+ fun:main
+}
+{
+ <dbus system bus setup 3>
+ Memcheck:Leak
+ ...
+ fun:dbus_malloc0
+ ...
+ fun:dbus_parse_address
+ ...
+ fun:g_dbus_setup_bus
+ fun:main
+}
+{
+ <libdbus internals 1>
+ Memcheck:Leak
+ fun:*malloc
+ ...
+ obj:/lib/libdbus-1.so.3.5.3
+}
+{
+ <dbus system bus setup 4>
+ Memcheck:Leak
+ fun:*alloc
+ ...
+ fun:dbus_*alloc*
+ ...
+ fun:g_dbus_setup_bus
+ fun:main
+}
+{
+ <dbus system bus setup 5>
+ Memcheck:Leak
+ fun:calloc
+ fun:g_malloc0
+ ...
+ fun:g_dbus_set_disconnect_function
+ fun:main
+}
+{
+ <dbus bus remove match>
+ Memcheck:Leak
+ fun:malloc
+ fun:g_malloc
+ fun:g_source_set_callback
+ fun:g_timeout_add_full
+ fun:g_timeout_add
+ ...
+ fun:dbus_pending_call_block
+ fun:dbus_connection_send_with_reply_and_block
+ ...
+ fun:dbus_bus_remove_match
+}
+{
+ <g_main_loop_run/new>
+ Memcheck:Leak
+ fun:*alloc
+ ...
+ fun:g_main_loop_*
+ fun:main
+}
+{
+ <g_main_context_dispatch>
+ Memcheck:Leak
+ fun:*alloc
+ ...
+ fun:g_main_context_dispatch
+}
+{
+ <libdbus internals 2>
+ Memcheck:Leak
+ fun:realloc
+ fun:dbus_realloc
+ ...
+ fun:dbus_message_set_reply_serial
+ fun:dbus_message_new_error
+ ...
+}
+{
+ <libdbus internals 3>
+ Memcheck:Leak
+ fun:realloc
+ fun:dbus_realloc
+ ...
+ fun:dbus_message_new_signal
+ ...
+}
+{
+ <dbus_bus_register>
+ Memcheck:Leak
+ fun:malloc
+ fun:realloc
+ fun:dbus_realloc
+ ...
+ fun:dbus_pending_call_block
+ fun:dbus_connection_send_with_reply_and_block
+ fun:dbus_bus_register
+}
+
--
1.7.9.5
^ permalink raw reply related
* Re: BLE : SMP pairing + LE_Start_encryption
From: Anderson Lizardo @ 2012-11-30 12:53 UTC (permalink / raw)
To: Ajay; +Cc: linux-bluetooth
In-Reply-To: <50B6ADE7.3070000@globaledgesoft.com>
Hi Ajay,
On Wed, Nov 28, 2012 at 8:35 PM, Ajay <ajay.kv@globaledgesoft.com> wrote:
> is it possible to create an l2cap connection with cid 0x06 and psm 0
> ? , so that i can make use of dedicated smp-l2cap channel for data transfer
> . I wanted to try how the remote device is handling on receiving an
> smp_pairing_request . i have seen in l2cap_core.c , it is getting handled
> inside a switch case (case cid == L2CAP_CID_SMP).
On Linux, all communication over the LE SMP CID is done on the kernel.
So you need to use either increase socket seclevel using setsockopt()
or using "Pair Device" from mgmt API to send the SMP Pairing Request
from userspace.
I don't know how you can send "raw" SMP requests from userspace.
Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply
* [PATCH BlueZ] control: Add methods FastForward and Rewind
From: Luiz Augusto von Dentz @ 2012-11-30 12:48 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
These method can be used to fast-forward and rewind the playback, their
action will keep active until another method is called.
The commands are reapeated every 2 seconds to conform with AVC spec.
---
doc/control-api.txt | 10 ++++
profiles/audio/avctp.c | 148 ++++++++++++++++++++++++++++++++++++++++++-----
profiles/audio/control.c | 14 +++++
3 files changed, 157 insertions(+), 15 deletions(-)
diff --git a/doc/control-api.txt b/doc/control-api.txt
index e0ed04a..55cebe8 100644
--- a/doc/control-api.txt
+++ b/doc/control-api.txt
@@ -40,6 +40,16 @@ Methods void Play()
Adjust remote volume one step down
+ void FastForward()
+
+ Fast forward playback, this action is only stopped
+ when another method in this interface is called.
+
+ void Rewind()
+
+ Rewind playback, this action is only stopped
+ when another method in this interface is called.
+
Properties
boolean Connected [readonly]
diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
index e48c257..8693784 100644
--- a/profiles/audio/avctp.c
+++ b/profiles/audio/avctp.c
@@ -162,6 +162,11 @@ struct avctp_channel {
guint process_id;
};
+struct key_pressed {
+ uint8_t op;
+ guint timer;
+};
+
struct avctp {
struct avctp_server *server;
bdaddr_t dst;
@@ -179,6 +184,7 @@ struct avctp {
struct avctp_channel *browsing;
uint8_t key_quirks[256];
+ struct key_pressed *key;
};
struct avctp_pdu_handler {
@@ -214,6 +220,9 @@ static GSList *servers = NULL;
static void auth_cb(DBusError *derr, void *user_data);
static gboolean process_queue(gpointer user_data);
+static gboolean avctp_passthrough_rsp(struct avctp *session, uint8_t code,
+ uint8_t subunit, uint8_t *operands,
+ size_t operand_count, void *user_data);
static int send_event(int fd, uint16_t type, uint16_t code, int32_t value)
{
@@ -409,6 +418,13 @@ static void avctp_disconnected(struct avctp *session)
session->auth_id = 0;
}
+ if (session->key != NULL) {
+ if (session->key->timer > 0)
+ g_source_remove(session->key->timer);
+ g_free(session->key);
+ }
+
+
if (session->uinput >= 0) {
char address[18];
@@ -1272,6 +1288,116 @@ static int avctp_send_req(struct avctp *session, uint8_t code,
return 0;
}
+static char *op2str(uint8_t op)
+{
+ switch (op & 0x7f) {
+ case AVC_VOLUME_UP:
+ return "VOLUME UP";
+ case AVC_VOLUME_DOWN:
+ return "VOLUME DOWN";
+ case AVC_MUTE:
+ return "MUTE";
+ case AVC_PLAY:
+ return "PLAY";
+ case AVC_STOP:
+ return "STOP";
+ case AVC_PAUSE:
+ return "PAUSE";
+ case AVC_RECORD:
+ return "RECORD";
+ case AVC_REWIND:
+ return "REWIND";
+ case AVC_FAST_FORWARD:
+ return "FAST FORWARD";
+ case AVC_EJECT:
+ return "EJECT";
+ case AVC_FORWARD:
+ return "FORWARD";
+ case AVC_BACKWARD:
+ return "BACKWARD";
+ default:
+ return "UNKNOWN";
+ }
+}
+
+static int avctp_passthrough_press(struct avctp *session, uint8_t op)
+{
+ uint8_t operands[2];
+
+ DBG("%s", op2str(op));
+
+ /* Button pressed */
+ operands[0] = op & 0x7f;
+ operands[1] = 0;
+
+ return avctp_send_req(session, AVC_CTYPE_CONTROL,
+ AVC_SUBUNIT_PANEL, AVC_OP_PASSTHROUGH,
+ operands, sizeof(operands),
+ avctp_passthrough_rsp, NULL);
+}
+
+static int avctp_passthrough_release(struct avctp *session, uint8_t op)
+{
+ uint8_t operands[2];
+
+ DBG("%s", op2str(op));
+
+ /* Button released */
+ operands[0] = op | 0x80;
+ operands[1] = 0;
+
+ return avctp_send_req(session, AVC_CTYPE_CONTROL,
+ AVC_SUBUNIT_PANEL, AVC_OP_PASSTHROUGH,
+ operands, sizeof(operands),
+ NULL, NULL);
+}
+
+static gboolean repeat_timeout(gpointer user_data)
+{
+ struct avctp *session = user_data;
+ struct key_pressed *key = session->key;
+
+ avctp_passthrough_release(session, key->op);
+ avctp_passthrough_press(session, key->op);
+
+ return TRUE;
+}
+
+static void release_pressed(struct avctp *session)
+{
+ struct key_pressed *key = session->key;
+
+ avctp_passthrough_release(session, key->op);
+
+ if (key->timer > 0)
+ g_source_remove(key->timer);
+
+ g_free(key);
+ session->key = NULL;
+}
+
+static bool set_pressed(struct avctp *session, uint8_t op)
+{
+ struct key_pressed *key;
+
+ if (session->key != NULL) {
+ if (session->key->op == op)
+ return TRUE;
+ release_pressed(session);
+ }
+
+ if (op != AVC_FAST_FORWARD && op != AVC_REWIND)
+ return FALSE;
+
+ key = g_new0(struct key_pressed, 1);
+ key->op = op;
+ key->timer = g_timeout_add_seconds(2, repeat_timeout, session);
+
+ session->key = key;
+
+ return TRUE;
+}
+
static gboolean avctp_passthrough_rsp(struct avctp *session, uint8_t code,
uint8_t subunit, uint8_t *operands,
size_t operand_count, void *user_data)
@@ -1279,29 +1405,21 @@ static gboolean avctp_passthrough_rsp(struct avctp *session, uint8_t code,
if (code != AVC_CTYPE_ACCEPTED)
return FALSE;
- /* Button release */
- operands[0] |= 0x80;
+ if (set_pressed(session, operands[0]))
+ return FALSE;
- avctp_send_req(session, AVC_CTYPE_CONTROL,
- AVC_SUBUNIT_PANEL, AVC_OP_PASSTHROUGH,
- operands, operand_count,
- NULL, NULL);
+ avctp_passthrough_release(session, operands[0]);
return FALSE;
}
int avctp_send_passthrough(struct avctp *session, uint8_t op)
{
- uint8_t operands[2];
-
- /* Button pressed */
- operands[0] = op & 0x7f;
- operands[1] = 0;
+ /* Auto release if key pressed */
+ if (session->key != NULL)
+ release_pressed(session);
- return avctp_send_req(session, AVC_CTYPE_CONTROL,
- AVC_SUBUNIT_PANEL, AVC_OP_PASSTHROUGH,
- operands, sizeof(operands),
- avctp_passthrough_rsp, NULL);
+ return avctp_passthrough_press(session, op);
}
int avctp_send_vendordep(struct avctp *session, uint8_t transaction,
diff --git a/profiles/audio/control.c b/profiles/audio/control.c
index 0013f8d..7299b7e 100644
--- a/profiles/audio/control.c
+++ b/profiles/audio/control.c
@@ -238,6 +238,18 @@ static DBusMessage *control_previous(DBusConnection *conn, DBusMessage *msg,
return key_pressed(conn, msg, AVC_BACKWARD, data);
}
+static DBusMessage *control_fast_forward(DBusConnection *conn, DBusMessage *msg,
+ void *data)
+{
+ return key_pressed(conn, msg, AVC_FAST_FORWARD, data);
+}
+
+static DBusMessage *control_rewind(DBusConnection *conn, DBusMessage *msg,
+ void *data)
+{
+ return key_pressed(conn, msg, AVC_REWIND, data);
+}
+
static gboolean control_property_get_connected(
const GDBusPropertyTable *property,
DBusMessageIter *iter, void *data)
@@ -258,6 +270,8 @@ static const GDBusMethodTable control_methods[] = {
{ GDBUS_METHOD("Previous", NULL, NULL, control_previous) },
{ GDBUS_METHOD("VolumeUp", NULL, NULL, control_volume_up) },
{ GDBUS_METHOD("VolumeDown", NULL, NULL, control_volume_down) },
+ { GDBUS_METHOD("FastForward", NULL, NULL, control_fast_forward) },
+ { GDBUS_METHOD("Rewind", NULL, NULL, control_rewind) },
{ }
};
--
1.7.11.7
^ permalink raw reply related
* Re: [RFC v2 02/15] test: Add utility library for python scripts
From: Anderson Lizardo @ 2012-11-30 12:28 UTC (permalink / raw)
To: Mikel Astiz; +Cc: linux-bluetooth, Mikel Astiz
In-Reply-To: <1354193256-30610-3-git-send-email-mikel.astiz.oss@gmail.com>
Hi Mikel,
On Thu, Nov 29, 2012 at 8:47 AM, Mikel Astiz <mikel.astiz.oss@gmail.com> wrote:
> +def find_adapter_in_objects(objects, pattern=None):
> + bus = dbus.SystemBus()
> + for path, ifaces in objects.iteritems():
> + adapter = ifaces.get(ADAPTER_INTERFACE)
> + if adapter == None:
> + continue
It is usually considered bad to use "== None" in Python. Either use
"adapter is None" or just "not adapter" (which is broader, but is
probably okay in this context).
> + if (pattern == None or pattern == adapter["Address"] or
> + path.endswith(pattern)):
Same here, better use "pattern is None" or "not pattern" (which will
also match empty strings, which will always match due to the
"endswith()" usage).
> + obj = bus.get_object(SERVICE_NAME, path)
> + return dbus.Interface(obj, ADAPTER_INTERFACE)
> + raise Exception("Bluetooth adapter not found")
Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply
* Re: BLE : SMP pairing + LE_Start_encryption
From: Anderson Lizardo @ 2012-11-30 12:08 UTC (permalink / raw)
To: Ajay; +Cc: linux-bluetooth
In-Reply-To: <50B681C7.1030207@globaledgesoft.com>
Hi Ajay,
On Wed, Nov 28, 2012 at 5:27 PM, Ajay <ajay.kv@globaledgesoft.com> wrote:
>
> Hi,
> how do i do smp pairing and ltk key distribution using l2cap socket
> connection? does bluez provide any tools for LE pairing . my ultimate
> result should be enabling LE_start_encryption , which requires ltk key
> distribution (which is a part of LE_pairing).
Either using mgmt API to do pairing (see mgmt_create_bonding() in
src/mgmt.c from bluez sources and doc/mgmt-api.txt for how to do this)
or increase socket security level to at least medium using
setsockopt() (see set_sec_level() in btio/btio.c for how to do this).
In summary, you will need to use BlueZ code as reference if you want
to do these things on your own. The easier route is to use BlueZ D-Bus
API to do pairing.
Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply
* Re: [PATCH 7/8] adaptername: Refactor adaptername_init/exit to fix exit path
From: Anderson Lizardo @ 2012-11-30 11:58 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <1354274703-15604-7-git-send-email-szymon.janc@tieto.com>
Ho Szymon,
On Fri, Nov 30, 2012 at 7:25 AM, Szymon Janc <szymon.janc@tieto.com> wrote:
> @@ -266,20 +265,33 @@ static struct btd_adapter_driver adaptername_driver = {
> .probe = adaptername_probe,
> };
>
> -static int adaptername_init(void)
> +struct inotify_data
> {
The opening "{" should be on the same line as "struct inotify_data".
> - int err;
> int inot_fd;
> - guint32 mask;
> + int watch_d;
> +};
>
> - err = btd_register_adapter_driver(&adaptername_driver);
> - if (err < 0)
> - return err;
> +static void destroy_cb(gpointer user_data)
> +{
> + struct inotify_data *data = user_data;
> +
> + inotify_rm_watch(data->inot_fd, data->watch_d);
> + g_free(data);
> +}
> +
> +static int adaptername_init(void)
> +{
> + guint32 mask;
> + GIOChannel *inotify;
> + int inot_fd;
> + int watch_d;
> + struct inotify_data *data;
>
> inot_fd = inotify_init();
> if (inot_fd < 0) {
> - error("Failed to setup inotify");
> - return 0;
> + int err = -errno;
> + error("Failed to setup inotify (%d)", err);
We usually print errors this way:
error("Failed to setup inotify: %s (%d)", strerror(-err), -err);
> + return err;
> }
>
> mask = IN_CLOSE_WRITE;
> @@ -290,30 +302,38 @@ static int adaptername_init(void)
>
> watch_d = inotify_add_watch(inot_fd, MACHINE_INFO_DIR, mask);
> if (watch_d < 0) {
> - error("Failed to setup watch for '%s'", MACHINE_INFO_DIR);
> + int err = -errno;
> + error("Failed to setup watch for '%s' (%d)", MACHINE_INFO_DIR,
> + err);
same here:
error("Failed to setup watch for '%s': %s (%d)", MACHINE_INFO_DIR,
strerror(-err), -err);
> close(inot_fd);
> - return 0;
> + return err;
> }
Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply
* Re: [PATCH 4/8] hog: Fix memory leak in suspend-dummy
From: Anderson Lizardo @ 2012-11-30 11:49 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <1354274703-15604-4-git-send-email-szymon.janc@tieto.com>
Hi Szymon,
On Fri, Nov 30, 2012 at 7:24 AM, Szymon Janc <szymon.janc@tieto.com> wrote:
> @@ -137,9 +133,9 @@ int suspend_init(suspend_event suspend, resume_event resume)
>
> void suspend_exit(void)
> {
> - if (fifoio) {
> - g_io_channel_shutdown(fifoio, FALSE, NULL);
> - g_io_channel_unref(fifoio);
> + if (watch) {
By convention, we try to use "if (watch > 0)" or "if (watch == 0)"
when checking whether watches are valid. In this case, "if (watch >
0)" is more appropriate.
> + g_source_remove(watch);
> + watch = 0;
> }
>
> remove(HOG_SUSPEND_FIFO);
Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply
* Re: [RFC v2 00/15] Manager/Adapter transition to ObjectManager
From: Mikel Astiz @ 2012-11-30 11:38 UTC (permalink / raw)
To: Lucas De Marchi; +Cc: linux-bluetooth, Mikel Astiz
In-Reply-To: <CAMOw1v4hsQa3VNT+qaF9eZPiu88G7cyd0jwTR=Bd1Pnj3yyQWw@mail.gmail.com>
Hi Lucas,
On Thu, Nov 29, 2012 at 7:12 PM, Lucas De Marchi
<lucas.demarchi@profusion.mobi> wrote:
> On Thu, Nov 29, 2012 at 10:47 AM, Mikel Astiz <mikel.astiz.oss@gmail.com> wrote:
>> From: Mikel Astiz <mikel.astiz@bmw-carit.de>
>>
>> Note that this patchset requires the gdbus fix affecting were the ObjectManager gets registered, as submitted by Luiz.
>
> Those were replaced with my patches today. Do my patches do what you need?
Yes, the patches (which are now pushed) do the job.
So at this point there is no other dependency and thus these patches
can be applied and tested with upstream master.
Cheers,
Mikel
^ permalink raw reply
* [PATCH 8/8] hog: Fix unregistering profile on exit
From: Szymon Janc @ 2012-11-30 11:25 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1354274703-15604-1-git-send-email-szymon.janc@tieto.com>
On exit should call btd_profile_unregister instead of
btd_profile_register. Fixes following:
16 bytes in 1 blocks are still reachable in loss record 54 of 215
at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4E7FA78: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E92CA2: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E93FC2: g_slist_append (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x17F6C2: btd_profile_register (profile.c:533)
by 0x171456: plugin_cleanup (plugin.c:242)
by 0x12164F: main (main.c:563)
16 bytes in 1 blocks are still reachable in loss record 37 of 215
at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4E7FA78: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E92CA2: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E93FC2: g_slist_append (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x17F6C2: btd_profile_register (profile.c:533)
by 0x1712EB: plugin_init (plugin.c:217)
by 0x1215D2: main (main.c:544)
---
profiles/input/hog_manager.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/profiles/input/hog_manager.c b/profiles/input/hog_manager.c
index 21ceb79..595b160 100644
--- a/profiles/input/hog_manager.c
+++ b/profiles/input/hog_manager.c
@@ -144,7 +144,7 @@ static void hog_manager_exit(void)
if (suspend_supported)
suspend_exit();
- btd_profile_register(&hog_profile);
+ btd_profile_unregister(&hog_profile);
}
static int hog_init(void)
--
1.7.9.5
^ permalink raw reply related
* [PATCH 7/8] adaptername: Refactor adaptername_init/exit to fix exit path
From: Szymon Janc @ 2012-11-30 11:25 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1354274703-15604-1-git-send-email-szymon.janc@tieto.com>
This makes adaptername plugin properly cleanup its fds on exit. Fixes
following warnings from valgrind:
16 bytes in 1 blocks are still reachable in loss record 42 of 221
at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4E7FA78: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E92CA2: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E93ABD: g_slist_prepend (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E78350: g_source_add_poll (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4EB5E32: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E6D0C3: g_io_add_watch_full (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x1565FA: adaptername_init (adaptername.c:302)
by 0x1712AB: plugin_init (plugin.c:217)
by 0x1215D2: main (main.c:544)
18 bytes in 1 blocks are still reachable in loss record 58 of 221
at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4E7FA78: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E942DD: g_strdup (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E78A69: g_source_set_name (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4EB5E0B: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E6D0C3: g_io_add_watch_full (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x1565FA: adaptername_init (adaptername.c:302)
by 0x1712AB: plugin_init (plugin.c:217)
by 0x1215D2: main (main.c:544)
32 bytes in 1 blocks are still reachable in loss record 86 of 221
at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4E7FA78: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E78722: g_source_set_callback (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E6D0DB: g_io_add_watch_full (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x1565FA: adaptername_init (adaptername.c:302)
by 0x1712AB: plugin_init (plugin.c:217)
by 0x1215D2: main (main.c:544)
32 bytes in 1 blocks are still reachable in loss record 87 of 221
at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4E7FA78: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E92CA2: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E77285: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E775AF: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E78115: g_source_attach (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E6D0E5: g_io_add_watch_full (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x1565FA: adaptername_init (adaptername.c:302)
by 0x1712AB: plugin_init (plugin.c:217)
by 0x1215D2: main (main.c:544)
120 bytes in 1 blocks are still reachable in loss record 167 of 221
at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4E7FA78: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4EB66F4: g_io_channel_unix_new (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x1565A9: adaptername_init (adaptername.c:298)
by 0x1712AB: plugin_init (plugin.c:217)
by 0x1215D2: main (main.c:544)
120 bytes in 1 blocks are still reachable in loss record 168 of 221
at 0x4C29DB4: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4E7FAE0: g_malloc0 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E78044: g_source_new (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4EB5DF9: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E6D0C3: g_io_add_watch_full (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x1565FA: adaptername_init (adaptername.c:302)
by 0x1712AB: plugin_init (plugin.c:217)
by 0x1215D2: main (main.c:544)
---
plugins/adaptername.c | 60 ++++++++++++++++++++++++++++++++-----------------
1 file changed, 40 insertions(+), 20 deletions(-)
diff --git a/plugins/adaptername.c b/plugins/adaptername.c
index 2013b7b..bb46c1b 100644
--- a/plugins/adaptername.c
+++ b/plugins/adaptername.c
@@ -50,8 +50,7 @@
#define MACHINE_INFO_DIR "/etc/"
#define MACHINE_INFO_FILE "machine-info"
-static GIOChannel *inotify = NULL;
-static int watch_d = -1;
+static guint watchid = 0;
/* This file is part of systemd's hostnamed functionality:
* http://0pointer.de/public/systemd-man/machine-info.html
@@ -266,20 +265,33 @@ static struct btd_adapter_driver adaptername_driver = {
.probe = adaptername_probe,
};
-static int adaptername_init(void)
+struct inotify_data
{
- int err;
int inot_fd;
- guint32 mask;
+ int watch_d;
+};
- err = btd_register_adapter_driver(&adaptername_driver);
- if (err < 0)
- return err;
+static void destroy_cb(gpointer user_data)
+{
+ struct inotify_data *data = user_data;
+
+ inotify_rm_watch(data->inot_fd, data->watch_d);
+ g_free(data);
+}
+
+static int adaptername_init(void)
+{
+ guint32 mask;
+ GIOChannel *inotify;
+ int inot_fd;
+ int watch_d;
+ struct inotify_data *data;
inot_fd = inotify_init();
if (inot_fd < 0) {
- error("Failed to setup inotify");
- return 0;
+ int err = -errno;
+ error("Failed to setup inotify (%d)", err);
+ return err;
}
mask = IN_CLOSE_WRITE;
@@ -290,30 +302,38 @@ static int adaptername_init(void)
watch_d = inotify_add_watch(inot_fd, MACHINE_INFO_DIR, mask);
if (watch_d < 0) {
- error("Failed to setup watch for '%s'", MACHINE_INFO_DIR);
+ int err = -errno;
+ error("Failed to setup watch for '%s' (%d)", MACHINE_INFO_DIR,
+ err);
close(inot_fd);
- return 0;
+ return err;
}
+ data = g_new(struct inotify_data, 1);
+ data->inot_fd = inot_fd;
+ data->watch_d = watch_d;
+
inotify = g_io_channel_unix_new(inot_fd);
g_io_channel_set_close_on_unref(inotify, TRUE);
g_io_channel_set_encoding(inotify, NULL, NULL);
g_io_channel_set_flags(inotify, G_IO_FLAG_NONBLOCK, NULL);
- g_io_add_watch(inotify, G_IO_IN, handle_inotify_cb, NULL);
+
+ watchid = g_io_add_watch_full(inotify, G_PRIORITY_DEFAULT, G_IO_IN,
+ handle_inotify_cb, data, destroy_cb);
+
+ g_io_channel_unref(inotify);
+
+ btd_register_adapter_driver(&adaptername_driver);
return 0;
}
static void adaptername_exit(void)
{
- if (watch_d >= 0 && inotify != NULL) {
- int inot_fd = g_io_channel_unix_get_fd(inotify);
- inotify_rm_watch(inot_fd, watch_d);
- }
- if (inotify != NULL) {
- g_io_channel_shutdown(inotify, FALSE, NULL);
- g_io_channel_unref(inotify);
+ if (watchid > 0) {
+ g_source_remove(watchid);
+ watchid = 0;
}
btd_unregister_adapter_driver(&adaptername_driver);
--
1.7.9.5
^ permalink raw reply related
* [PATCH 6/8] core: Free parsed options
From: Szymon Janc @ 2012-11-30 11:25 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1354274703-15604-1-git-send-email-szymon.janc@tieto.com>
There is no need to keep already parsed options in memory. This also
fix not freeing options at all.
2 bytes in 1 blocks are still reachable in loss record 1 of 153
at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4E7FA78: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E942DD: g_strdup (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x167333: parse_debug (main.c:425)
by 0x4E839D8: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E8403F: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E85233: g_option_context_parse (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x121084: main (main.c:462)
16 bytes in 2 blocks are still reachable in loss record 39 of 153
at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4E7FA78: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E5D68B: g_convert_with_iconv (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E5D94B: g_convert (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E5DFBA: g_locale_to_utf8 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E837C7: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E8403F: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E85233: g_option_context_parse (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x121084: main (main.c:462)
---
src/main.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/main.c b/src/main.c
index ccb5fa5..bc53a8e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -344,6 +344,18 @@ static gboolean option_detach = TRUE;
static gboolean option_version = FALSE;
static gboolean option_udev = FALSE;
+static void free_options(void)
+{
+ g_free(option_debug);
+ option_debug = NULL;
+
+ g_free(option_plugin);
+ option_plugin = NULL;
+
+ g_free(option_noplugin);
+ option_noplugin = NULL;
+}
+
static guint last_adapter_timeout = 0;
static gboolean exit_timeout(gpointer data)
@@ -533,6 +545,9 @@ int main(int argc, char *argv[])
* daemon needs to be re-worked. */
plugin_init(config, option_plugin, option_noplugin);
+ /* no need to keep parsed option in memory */
+ free_options();
+
mgmt_err = mgmt_setup();
if (mgmt_err < 0) {
error("mgmt setup failed: %s", strerror(-mgmt_err));
--
1.7.9.5
^ permalink raw reply related
* [PATCH 5/8] attrib: Fix possible use after free
From: Szymon Janc @ 2012-11-30 11:25 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1354274703-15604-1-git-send-email-szymon.janc@tieto.com>
Move io channels unrefs after last use of channels.
---
src/attrib-server.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/attrib-server.c b/src/attrib-server.c
index 8e20903..1a9bd69 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -127,13 +127,13 @@ static void gatt_server_free(struct gatt_server *server)
g_list_free_full(server->database, attrib_free);
if (server->l2cap_io != NULL) {
- g_io_channel_unref(server->l2cap_io);
g_io_channel_shutdown(server->l2cap_io, FALSE, NULL);
+ g_io_channel_unref(server->l2cap_io);
}
if (server->le_io != NULL) {
- g_io_channel_unref(server->le_io);
g_io_channel_shutdown(server->le_io, FALSE, NULL);
+ g_io_channel_unref(server->le_io);
}
g_slist_free_full(server->clients, (GDestroyNotify) channel_free);
--
1.7.9.5
^ permalink raw reply related
* [PATCH 4/8] hog: Fix memory leak in suspend-dummy
From: Szymon Janc @ 2012-11-30 11:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1354274703-15604-1-git-send-email-szymon.janc@tieto.com>
g_io_add_watch increase channel ref count but g_io_channel_shutdown
doesn't drop reference nor remove watch. Since close on unref is set
for channel and it is watch we are interested keep watch id and not
channel id and remove watch on exit.
6 bytes in 1 blocks are still reachable in loss record 11 of 235
at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4E7FA78: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E942DD: g_strdup (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E6CF95: g_io_channel_init (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4EB66FF: g_io_channel_unix_new (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x18DDC5: fifo_open (suspend.c:109)
by 0x18DF95: suspend_init (suspend.c:131)
by 0x140B53: hog_init (hog_manager.c:133)
by 0x17127B: plugin_init (plugin.c:217)
by 0x1215D2: main (main.c:532)
16 bytes in 1 blocks are still reachable in loss record 45 of 235
at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4E7FA78: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E92CA2: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E93ABD: g_slist_prepend (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E78350: g_source_add_poll (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4EB5E32: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E6D0C3: g_io_add_watch_full (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x18DDF3: fifo_open (suspend.c:112)
by 0x18DF95: suspend_init (suspend.c:131)
by 0x140B53: hog_init (hog_manager.c:133)
by 0x17127B: plugin_init (plugin.c:217)
by 0x1215D2: main (main.c:532)
18 bytes in 1 blocks are still reachable in loss record 63 of 235
at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4E7FA78: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E942DD: g_strdup (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E78A69: g_source_set_name (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4EB5E0B: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E6D0C3: g_io_add_watch_full (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x18DDF3: fifo_open (suspend.c:112)
by 0x18DF95: suspend_init (suspend.c:131)
by 0x140B53: hog_init (hog_manager.c:133)
by 0x17127B: plugin_init (plugin.c:217)
by 0x1215D2: main (main.c:532)
32 bytes in 1 blocks are still reachable in loss record 93 of 235
at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4E7FA78: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E78722: g_source_set_callback (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E6D0DB: g_io_add_watch_full (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x18DDF3: fifo_open (suspend.c:112)
by 0x18DF95: suspend_init (suspend.c:131)
by 0x140B53: hog_init (hog_manager.c:133)
by 0x17127B: plugin_init (plugin.c:217)
by 0x1215D2: main (main.c:532)
32 bytes in 1 blocks are still reachable in loss record 94 of 235
at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4E7FA78: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E92CA2: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E77285: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E775AF: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E78115: g_source_attach (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E6D0E5: g_io_add_watch_full (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x18DDF3: fifo_open (suspend.c:112)
by 0x18DF95: suspend_init (suspend.c:131)
by 0x140B53: hog_init (hog_manager.c:133)
by 0x17127B: plugin_init (plugin.c:217)
by 0x1215D2: main (main.c:532)
120 bytes in 1 blocks are still reachable in loss record 177 of 235
at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4E7FA78: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4EB66F4: g_io_channel_unix_new (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x18DDC5: fifo_open (suspend.c:109)
by 0x18DF95: suspend_init (suspend.c:131)
by 0x140B53: hog_init (hog_manager.c:133)
by 0x17127B: plugin_init (plugin.c:217)
by 0x1215D2: main (main.c:532)
120 bytes in 1 blocks are still reachable in loss record 178 of 235
at 0x4C29DB4: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4E7FAE0: g_malloc0 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E78044: g_source_new (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4EB5DF9: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E6D0C3: g_io_add_watch_full (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x18DDF3: fifo_open (suspend.c:112)
by 0x18DF95: suspend_init (suspend.c:131)
by 0x140B53: hog_init (hog_manager.c:133)
by 0x17127B: plugin_init (plugin.c:217)
by 0x1215D2: main (main.c:532)
---
profiles/input/suspend-dummy.c | 38 +++++++++++++++++---------------------
1 file changed, 17 insertions(+), 21 deletions(-)
diff --git a/profiles/input/suspend-dummy.c b/profiles/input/suspend-dummy.c
index 58f7b9c..97636ae 100644
--- a/profiles/input/suspend-dummy.c
+++ b/profiles/input/suspend-dummy.c
@@ -44,7 +44,7 @@
static suspend_event suspend_cb = NULL;
static resume_event resume_cb = NULL;
-static GIOChannel *fifoio = NULL;
+static guint watch = 0;
static int fifo_open(void);
@@ -54,8 +54,15 @@ static gboolean read_fifo(GIOChannel *io, GIOCondition cond, gpointer user_data)
gsize offset, left, bread;
GIOStatus iostatus;
- if (cond & (G_IO_ERR | G_IO_HUP))
- goto failed;
+ if (cond & (G_IO_ERR | G_IO_HUP)) {
+ /*
+ * Both ends needs to be open simultaneously before proceeding
+ * any input or output operation. When the remote closes the
+ * channel, hup signal is received on this end.
+ */
+ fifo_open();
+ return FALSE;
+ }
offset = 0;
left = sizeof(buffer) - 1;
@@ -77,25 +84,12 @@ static gboolean read_fifo(GIOChannel *io, GIOCondition cond, gpointer user_data)
resume_cb();
return TRUE;
-
-failed:
- /*
- * Both ends needs to be open simultaneously before proceeding
- * any input or output operation. When the remote closes the
- * channel, hup signal is received on this end.
- */
-
- g_io_channel_unref(fifoio);
- fifoio = NULL;
-
- fifo_open();
-
- return FALSE;
}
static int fifo_open(void)
{
GIOCondition condition = G_IO_IN | G_IO_ERR | G_IO_HUP;
+ GIOChannel *fifoio;
int fd;
fd = open(HOG_SUSPEND_FIFO, O_RDONLY | O_NONBLOCK);
@@ -109,7 +103,9 @@ static int fifo_open(void)
fifoio = g_io_channel_unix_new(fd);
g_io_channel_set_close_on_unref(fifoio, TRUE);
- g_io_add_watch(fifoio, condition, read_fifo, NULL);
+ watch = g_io_add_watch(fifoio, condition, read_fifo, NULL);
+
+ g_io_channel_unref(fifoio);
return 0;
}
@@ -137,9 +133,9 @@ int suspend_init(suspend_event suspend, resume_event resume)
void suspend_exit(void)
{
- if (fifoio) {
- g_io_channel_shutdown(fifoio, FALSE, NULL);
- g_io_channel_unref(fifoio);
+ if (watch) {
+ g_source_remove(watch);
+ watch = 0;
}
remove(HOG_SUSPEND_FIFO);
--
1.7.9.5
^ permalink raw reply related
* [PATCH 3/8] rfkill: Fix memory leak in rfkill_exit
From: Szymon Janc @ 2012-11-30 11:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1354274703-15604-1-git-send-email-szymon.janc@tieto.com>
g_io_add_watch increase channel ref count but g_io_channel_shutdown
doesn't drop reference nor remove watch. Since close on unref is set
for channel and it is watch we are interested keep watch id and not
channel id and remove watch on exit.
120 bytes in 1 blocks are still reachable in loss record 181 of 235
at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4E7FA78: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4EB66F4: g_io_channel_unix_new (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x167B8D: rfkill_init (rfkill.c:157)
by 0x1215E4: main (main.c:540)
6 bytes in 1 blocks are still reachable in loss record 12 of 235
at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4E7FA78: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E942DD: g_strdup (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E6CF95: g_io_channel_init (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4EB66FF: g_io_channel_unix_new (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x167B8D: rfkill_init (rfkill.c:157)
by 0x1215E4: main (main.c:540)
---
src/rfkill.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/rfkill.c b/src/rfkill.c
index b40c6e7..a6cd95c 100644
--- a/src/rfkill.c
+++ b/src/rfkill.c
@@ -139,11 +139,12 @@ static gboolean rfkill_event(GIOChannel *chan,
return TRUE;
}
-static GIOChannel *channel = NULL;
+static guint watch = 0;
void rfkill_init(void)
{
int fd;
+ GIOChannel *channel;
if (!main_opts.remember_powered)
return;
@@ -157,17 +158,17 @@ void rfkill_init(void)
channel = g_io_channel_unix_new(fd);
g_io_channel_set_close_on_unref(channel, TRUE);
- g_io_add_watch(channel, G_IO_IN | G_IO_NVAL | G_IO_HUP | G_IO_ERR,
+ watch = g_io_add_watch(channel, G_IO_IN | G_IO_NVAL | G_IO_HUP | G_IO_ERR,
rfkill_event, NULL);
+
+ g_io_channel_unref(channel);
}
void rfkill_exit(void)
{
- if (!channel)
+ if (watch == 0)
return;
- g_io_channel_shutdown(channel, TRUE, NULL);
- g_io_channel_unref(channel);
-
- channel = NULL;
+ g_source_remove(watch);
+ watch = 0;
}
--
1.7.9.5
^ permalink raw reply related
* [PATCH 2/8] doc: Update valgrind.suppressions with some libdbus suppressions
From: Szymon Janc @ 2012-11-30 11:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1354274703-15604-1-git-send-email-szymon.janc@tieto.com>
Suppress some useless libdbus warnings.
---
doc/valgrind.suppressions | 81 ++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 80 insertions(+), 1 deletion(-)
diff --git a/doc/valgrind.suppressions b/doc/valgrind.suppressions
index 5967a15..81d2227 100644
--- a/doc/valgrind.suppressions
+++ b/doc/valgrind.suppressions
@@ -233,4 +233,83 @@
fun:dbus_connection_send_with_reply_and_block
fun:dbus_bus_register
}
-
+{
+ <insert_a_suppression_name_here>
+ Memcheck:Leak
+ fun:malloc
+ ...
+ obj:/lib/*/libdbus-*
+ ...
+ fun:g_dbus_setup_bus
+}
+{
+ <insert_a_suppression_name_here>
+ Memcheck:Leak
+ fun:calloc
+ ...
+ obj:/lib/*/libdbus-*
+ ...
+ fun:g_dbus_setup_bus
+ fun:connect_dbus
+ ...
+}
+{
+ <insert_a_suppression_name_here>
+ Memcheck:Leak
+ fun:realloc
+ ...
+ obj:/lib/*/libdbus-*
+ ...
+ fun:dbus_connection_send_with_reply_and_block
+ fun:dbus_bus_register
+ ...
+}
+{
+ <insert_a_suppression_name_here>
+ Memcheck:Leak
+ fun:calloc
+ ...
+ obj:/lib/*/libdbus-*
+ ...
+ fun:dbus_connection_send_with_reply_and_block
+ fun:dbus_bus_register
+ ...
+}
+{
+ <insert_a_suppression_name_here>
+ Memcheck:Leak
+ fun:malloc
+ ...
+ obj:/lib/*/libdbus-*
+ ...
+ fun:dbus_connection_send_with_reply_and_block
+ fun:dbus_bus_register
+ ...
+}
+{
+ <insert_a_suppression_name_here>
+ Memcheck:Leak
+ fun:calloc
+ ...
+ obj:/lib/*/libdbus-*
+ ...
+ fun:dbus_connection_send_with_reply_and_block
+ fun:dbus_bus_request_name
+}
+{
+ <insert_a_suppression_name_here>
+ Memcheck:Leak
+ fun:realloc
+ ...
+ obj:/lib/*/libdbus-*
+ ...
+ fun:dbus_connection_send_with_reply_and_block
+ fun:dbus_bus_request_name
+}
+{
+ <insert_a_suppression_name_here>
+ Memcheck:Leak
+ fun:realloc
+ ...
+ obj:/lib/*/libdbus-*
+}
--
1.7.9.5
^ permalink raw reply related
* [PATCH 1/8] doc: Add valgrind.suppressions
From: Szymon Janc @ 2012-11-30 11:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
Shamelessly copied from connman.
---
doc/valgrind.suppressions | 236 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 236 insertions(+)
create mode 100644 doc/valgrind.suppressions
diff --git a/doc/valgrind.suppressions b/doc/valgrind.suppressions
new file mode 100644
index 0000000..5967a15
--- /dev/null
+++ b/doc/valgrind.suppressions
@@ -0,0 +1,236 @@
+{
+ <syslog error>
+ Memcheck:Cond
+ obj:/lib/libc-*.so
+ ...
+ fun:localtime_r
+ fun:__vsyslog_chk
+ fun:__syslog_chk
+ fun:__connman_log_init
+ ...
+}
+{
+ <iconv open>
+ Memcheck:Addr4
+ obj:/lib/libc-*.so
+ obj:/lib/libglib-2.0.so*
+ fun:g_iconv_open
+ ...
+ fun:g_convert
+ fun:g_locale_to_utf8
+ fun:g_strerror
+ fun:g_key_file_load_from_file
+ ...
+}
+{
+ <ioctl ADDRT/DELRT>
+ Memcheck:Param
+ ioctl(SIOCADDRT/DELRT)
+ obj:/lib/ld-*.so
+ ...
+}
+{
+ <g_main_loop>
+ Memcheck:Leak
+ fun:memalign
+ ...
+ fun:g_slice_alloc
+ ...
+ fun:g_main_loop_new
+ ...
+}
+{
+ <g_option_context_parse>
+ Memcheck:Leak
+ ...
+ fun:g_slice_alloc
+ ...
+ fun:g_option_context_parse
+ ...
+}
+{
+ <g_key_file_load_from_data>
+ Memcheck:Leak
+ ...
+ fun:g_slice_alloc
+ ...
+ fun:g_key_file_load_from_data
+ ...
+}
+{
+ <g_key_file_new 1>
+ Memcheck:Leak
+ ...
+ fun:g_slice_alloc
+ ...
+ fun:g_key_file_new
+ ...
+}
+{
+ <g_key_file_new 2>
+ Memcheck:Leak
+ fun:*alloc
+ ...
+ fun:g_key_file_new
+ fun:main
+}
+{
+ <connman plugin cleanup>
+ Memcheck:Leak
+ ...
+ fun:__connman_plugin_cleanup
+ ...
+}
+{
+ <cmd line option parsing>
+ Memcheck:Leak
+ fun:malloc
+ fun:g_malloc
+ fun:g_strdup
+ fun:g_set_prgname
+ fun:g_option_context_parse
+ fun:main
+}
+{
+ <dbus system bus setup 1>
+ Memcheck:Leak
+ ...
+ fun:dbus_malloc*
+ ...
+ fun:g_dbus_setup_bus
+ fun:main
+}
+{
+ <dbus system bus setup 2>
+ Memcheck:Leak
+ ...
+ fun:g_malloc*
+ ...
+ fun:dbus_connection_set_watch_functions
+ fun:setup_bus
+ ...
+}
+{
+ <key file get charset>
+ Memcheck:Leak
+ ...
+ fun:g_*alloc*
+ ...
+ fun:g_strerror
+ fun:g_key_file_load_from_file
+ fun:main
+}
+{
+ <dbus disconnect func set>
+ Memcheck:Leak
+ ...
+ fun:filter_data_get
+ fun:g_dbus_add_signal_watch
+ fun:g_dbus_set_disconnect_function
+ fun:main
+}
+{
+ <plugin dlopen>
+ Memcheck:Leak
+ ...
+ fun:dlopen
+ fun:__connman_plugin_init
+ fun:main
+}
+{
+ <dbus system bus setup 3>
+ Memcheck:Leak
+ ...
+ fun:dbus_malloc0
+ ...
+ fun:dbus_parse_address
+ ...
+ fun:g_dbus_setup_bus
+ fun:main
+}
+{
+ <libdbus internals 1>
+ Memcheck:Leak
+ fun:*malloc
+ ...
+ obj:/lib/libdbus-1.so.3.5.3
+}
+{
+ <dbus system bus setup 4>
+ Memcheck:Leak
+ fun:*alloc
+ ...
+ fun:dbus_*alloc*
+ ...
+ fun:g_dbus_setup_bus
+ fun:main
+}
+{
+ <dbus system bus setup 5>
+ Memcheck:Leak
+ fun:calloc
+ fun:g_malloc0
+ ...
+ fun:g_dbus_set_disconnect_function
+ fun:main
+}
+{
+ <dbus bus remove match>
+ Memcheck:Leak
+ fun:malloc
+ fun:g_malloc
+ fun:g_source_set_callback
+ fun:g_timeout_add_full
+ fun:g_timeout_add
+ ...
+ fun:dbus_pending_call_block
+ fun:dbus_connection_send_with_reply_and_block
+ ...
+ fun:dbus_bus_remove_match
+}
+{
+ <g_main_loop_run/new>
+ Memcheck:Leak
+ fun:*alloc
+ ...
+ fun:g_main_loop_*
+ fun:main
+}
+{
+ <g_main_context_dispatch>
+ Memcheck:Leak
+ fun:*alloc
+ ...
+ fun:g_main_context_dispatch
+}
+{
+ <libdbus internals 2>
+ Memcheck:Leak
+ fun:realloc
+ fun:dbus_realloc
+ ...
+ fun:dbus_message_set_reply_serial
+ fun:dbus_message_new_error
+ ...
+}
+{
+ <libdbus internals 3>
+ Memcheck:Leak
+ fun:realloc
+ fun:dbus_realloc
+ ...
+ fun:dbus_message_new_signal
+ ...
+}
+{
+ <dbus_bus_register>
+ Memcheck:Leak
+ fun:malloc
+ fun:realloc
+ fun:dbus_realloc
+ ...
+ fun:dbus_pending_call_block
+ fun:dbus_connection_send_with_reply_and_block
+ fun:dbus_bus_register
+}
+
--
1.7.9.5
^ permalink raw reply related
* Re: [PATCH BlueZ 1/6] gdbus: Add g_dbus_add_properties_watch function
From: Johan Hedberg @ 2012-11-30 8:31 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1354020685-17028-1-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On Tue, Nov 27, 2012, Luiz Augusto von Dentz wrote:
> Convenient function to create watches for D-Bus properties.
> ---
> gdbus/gdbus.h | 5 +++++
> gdbus/watch.c | 28 ++++++++++++++++++++++++++++
> 2 files changed, 33 insertions(+)
All patches in this set have been applied. Thanks.
Johan
^ permalink raw reply
* Re: [RFC v2 00/15] Manager/Adapter transition to ObjectManager
From: Lucas De Marchi @ 2012-11-29 18:12 UTC (permalink / raw)
To: Mikel Astiz; +Cc: linux-bluetooth, Mikel Astiz
In-Reply-To: <1354193256-30610-1-git-send-email-mikel.astiz.oss@gmail.com>
On Thu, Nov 29, 2012 at 10:47 AM, Mikel Astiz <mikel.astiz.oss@gmail.com> wrote:
> From: Mikel Astiz <mikel.astiz@bmw-carit.de>
>
> Note that this patchset requires the gdbus fix affecting were the ObjectManager gets registered, as submitted by Luiz.
Those were replaced with my patches today. Do my patches do what you need?
Lucas De Marchi
^ permalink raw reply
* [PATCHv2 4/4] Bluetooth: trivial: Change NO_FCS_RECV to RECV_NO_FCS
From: Andrei Emeltchenko @ 2012-11-29 15:46 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1354203968-1335-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Make code more readable by changing CONF_NO_FCS_RECV which is read
as "No L2CAP FCS option received" to CONF_RECV_NO_FCS which means
"Received L2CAP option NO_FCS". This flag really means that we have
received L2CAP FRAME CHECK SEQUENCE (FCS) OPTION with value "No FCS".
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
include/net/bluetooth/l2cap.h | 2 +-
net/bluetooth/l2cap_core.c | 10 +++++-----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index f57fab0..7588ef4 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -611,7 +611,7 @@ enum {
CONF_MTU_DONE,
CONF_MODE_DONE,
CONF_CONNECT_PEND,
- CONF_NO_FCS_RECV,
+ CONF_RECV_NO_FCS,
CONF_STATE2_DEVICE,
CONF_EWS_RECV,
CONF_LOC_CONF_PEND,
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 8c43277..2c78208 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3112,7 +3112,7 @@ done:
if (chan->conn->feat_mask & L2CAP_FEAT_FCS)
if (chan->fcs == L2CAP_FCS_NONE ||
- test_bit(CONF_NO_FCS_RECV, &chan->conf_state)) {
+ test_bit(CONF_RECV_NO_FCS, &chan->conf_state)) {
chan->fcs = L2CAP_FCS_NONE;
l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1,
chan->fcs);
@@ -3140,7 +3140,7 @@ done:
if (chan->conn->feat_mask & L2CAP_FEAT_FCS)
if (chan->fcs == L2CAP_FCS_NONE ||
- test_bit(CONF_NO_FCS_RECV, &chan->conf_state)) {
+ test_bit(CONF_RECV_NO_FCS, &chan->conf_state)) {
chan->fcs = L2CAP_FCS_NONE;
l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1,
chan->fcs);
@@ -3196,7 +3196,7 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data)
case L2CAP_CONF_FCS:
if (val == L2CAP_FCS_NONE)
- set_bit(CONF_NO_FCS_RECV, &chan->conf_state);
+ set_bit(CONF_RECV_NO_FCS, &chan->conf_state);
break;
case L2CAP_CONF_EFS:
@@ -3435,7 +3435,7 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
case L2CAP_CONF_FCS:
if (*result == L2CAP_CONF_PENDING)
if (val == L2CAP_FCS_NONE)
- set_bit(CONF_NO_FCS_RECV,
+ set_bit(CONF_RECV_NO_FCS,
&chan->conf_state);
break;
}
@@ -3807,7 +3807,7 @@ static inline void set_default_fcs(struct l2cap_chan *chan)
*/
if (chan->mode != L2CAP_MODE_ERTM && chan->mode != L2CAP_MODE_STREAMING)
chan->fcs = L2CAP_FCS_NONE;
- else if (!test_bit(CONF_NO_FCS_RECV, &chan->conf_state))
+ else if (!test_bit(CONF_RECV_NO_FCS, &chan->conf_state))
chan->fcs = L2CAP_FCS_CRC16;
}
--
1.7.10.4
^ permalink raw reply related
* [PATCHv2 3/4] Bluetooth: Process receiving FCS_NONE in L2CAP Conf Rsp
From: Andrei Emeltchenko @ 2012-11-29 15:46 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1354203968-1335-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Process L2CAP Config rsp Pending with FCS Option 0x00 (No FCS)
which is sent by Motorola Windows 7 Bluetooth stack. The trace
is shown below (all other options are skipped).
...
< ACL data: handle 1 flags 0x00 dlen 48
L2CAP(s): Config req: dcid 0x0043 flags 0x00 clen 36
...
FCS Option 0x00 (No FCS)
> ACL data: handle 1 flags 0x02 dlen 48
L2CAP(s): Config req: dcid 0x0041 flags 0x00 clen 36
...
FCS Option 0x01 (CRC16 Check)
< ACL data: handle 1 flags 0x00 dlen 47
L2CAP(s): Config rsp: scid 0x0043 flags 0x00 result 4 clen 33
Pending
...
> ACL data: handle 1 flags 0x02 dlen 50
L2CAP(s): Config rsp: scid 0x0041 flags 0x00 result 4 clen 36
Pending
...
FCS Option 0x00 (No FCS)
< ACL data: handle 1 flags 0x00 dlen 14
L2CAP(s): Config rsp: scid 0x0043 flags 0x00 result 0 clen 0
Success
> ACL data: handle 1 flags 0x02 dlen 14
L2CAP(s): Config rsp: scid 0x0041 flags 0x00 result 0 clen 0
Success
...
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
net/bluetooth/l2cap_core.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index d22d183..8c43277 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3431,6 +3431,13 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, sizeof(efs),
(unsigned long) &efs);
break;
+
+ case L2CAP_CONF_FCS:
+ if (*result == L2CAP_CONF_PENDING)
+ if (val == L2CAP_FCS_NONE)
+ set_bit(CONF_NO_FCS_RECV,
+ &chan->conf_state);
+ break;
}
}
--
1.7.10.4
^ permalink raw reply related
* [PATCHv2 2/4] Bluetooth: Fix missing L2CAP EWS Conf parameter
From: Andrei Emeltchenko @ 2012-11-29 15:46 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1354203968-1335-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
If L2CAP_FEAT_FCS is not supported we sould miss EWS option
configuration because of break. Make code more readable by
combining FCS configuration in the single block.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
net/bluetooth/l2cap_core.c | 32 +++++++++++++++-----------------
1 file changed, 15 insertions(+), 17 deletions(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index d8cffdb..d22d183 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3106,18 +3106,17 @@ done:
if (test_bit(FLAG_EFS_ENABLE, &chan->flags))
l2cap_add_opt_efs(&ptr, chan);
- if (!(chan->conn->feat_mask & L2CAP_FEAT_FCS))
- break;
-
- if (chan->fcs == L2CAP_FCS_NONE ||
- test_bit(CONF_NO_FCS_RECV, &chan->conf_state)) {
- chan->fcs = L2CAP_FCS_NONE;
- l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1, chan->fcs);
- }
-
if (test_bit(FLAG_EXT_CTRL, &chan->flags))
l2cap_add_conf_opt(&ptr, L2CAP_CONF_EWS, 2,
chan->tx_win);
+
+ if (chan->conn->feat_mask & L2CAP_FEAT_FCS)
+ if (chan->fcs == L2CAP_FCS_NONE ||
+ test_bit(CONF_NO_FCS_RECV, &chan->conf_state)) {
+ chan->fcs = L2CAP_FCS_NONE;
+ l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1,
+ chan->fcs);
+ }
break;
case L2CAP_MODE_STREAMING:
@@ -3139,14 +3138,13 @@ done:
if (test_bit(FLAG_EFS_ENABLE, &chan->flags))
l2cap_add_opt_efs(&ptr, chan);
- if (!(chan->conn->feat_mask & L2CAP_FEAT_FCS))
- break;
-
- if (chan->fcs == L2CAP_FCS_NONE ||
- test_bit(CONF_NO_FCS_RECV, &chan->conf_state)) {
- chan->fcs = L2CAP_FCS_NONE;
- l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1, chan->fcs);
- }
+ if (chan->conn->feat_mask & L2CAP_FEAT_FCS)
+ if (chan->fcs == L2CAP_FCS_NONE ||
+ test_bit(CONF_NO_FCS_RECV, &chan->conf_state)) {
+ chan->fcs = L2CAP_FCS_NONE;
+ l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1,
+ chan->fcs);
+ }
break;
}
--
1.7.10.4
^ permalink raw reply related
* [PATCHv2 1/4] Bluetooth: AMP: Check that AMP is present and active
From: Andrei Emeltchenko @ 2012-11-29 15:46 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <20121129103405.GC26707@joana>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Before starting quering remote AMP controllers make sure
that there is local active AMP controller.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
include/net/bluetooth/hci_core.h | 16 ++++++++++++++++
net/bluetooth/l2cap_core.c | 1 +
2 files changed, 17 insertions(+)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 2f2b743..014a2ea 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -779,6 +779,22 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
#define lmp_host_le_capable(dev) !!((dev)->host_features[0] & LMP_HOST_LE)
#define lmp_host_le_br_capable(dev) !!((dev)->host_features[0] & LMP_HOST_LE_BREDR)
+/* returns true if at least one AMP active */
+static inline bool hci_amp_capable(void)
+{
+ struct hci_dev *hdev;
+ bool ret = false;
+
+ read_lock(&hci_dev_list_lock);
+ list_for_each_entry(hdev, &hci_dev_list, list)
+ if (hdev->amp_type == HCI_AMP &&
+ test_bit(HCI_UP, &hdev->flags))
+ ret = true;
+ read_unlock(&hci_dev_list_lock);
+
+ return ret;
+}
+
/* ----- HCI protocols ----- */
#define HCI_PROTO_DEFER 0x01
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index f7ee037..d8cffdb 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1013,6 +1013,7 @@ static bool __amp_capable(struct l2cap_chan *chan)
struct l2cap_conn *conn = chan->conn;
if (enable_hs &&
+ hci_amp_capable() &&
chan->chan_policy == BT_CHANNEL_POLICY_AMP_PREFERRED &&
conn->fixed_chan_mask & L2CAP_FC_A2MP)
return true;
--
1.7.10.4
^ permalink raw reply related
* Re: [PATCH BlueZ 1/3] gdbus: Don't register DBus.Properties with no properties
From: Luiz Augusto von Dentz @ 2012-11-29 14:37 UTC (permalink / raw)
To: Lucas De Marchi; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <CABBYNZJVfiD36XrnNyn-5i5MqcOi-LKJ3QMREC6E+XpC9+1CyQ@mail.gmail.com>
Hi Lucas,
On Thu, Nov 29, 2012 at 3:33 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> Hi Lucas,
>
> On Thu, Nov 29, 2012 at 3:19 PM, Lucas De Marchi
> <lucas.demarchi@profusion.mobi> wrote:
>> Delay registering DBus.Properties interface until the moment there are
>> properties on that path. This is needed for objects that currently don't
>> expose any property to not export the interface.
>> ---
>> gdbus/object.c | 9 ++++++---
>> 1 file changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/gdbus/object.c b/gdbus/object.c
>> index 3101ca6..47116bd 100644
>> --- a/gdbus/object.c
>> +++ b/gdbus/object.c
>> @@ -1213,9 +1213,6 @@ static struct generic_data *object_path_ref(DBusConnection *connection,
>> manager_methods, manager_signals,
>> NULL, data, NULL);
>>
>> - add_interface(data, DBUS_INTERFACE_PROPERTIES, properties_methods,
>> - properties_signals, NULL, data, NULL);
>> -
>> return data;
>> }
>>
>> @@ -1336,6 +1333,12 @@ gboolean g_dbus_register_interface(DBusConnection *connection,
>> return FALSE;
>> }
>>
>> + if (properties != NULL && !find_interface(data->interfaces,
>> + DBUS_INTERFACE_PROPERTIES))
>> + add_interface(data, DBUS_INTERFACE_PROPERTIES,
>> + properties_methods, properties_signals, NULL,
>> + data, NULL);
>> +
>> add_interface(data, name, methods, signals, properties, user_data,
>> destroy);
>>
>> --
>> 1.8.0.1
>
> Ack
Patches pushed to BlueZ and obexd. Thanks.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH] control: Remove duplicated documentation entry
From: Johan Hedberg @ 2012-11-29 13:59 UTC (permalink / raw)
To: João Paulo Rechi Vita; +Cc: linux-bluetooth
In-Reply-To: <1354196335-3366-1-git-send-email-jprvita@openbossa.org>
Hi João Paulo,
On Thu, Nov 29, 2012, João Paulo Rechi Vita wrote:
> ---
> doc/control-api.txt | 4 ----
> 1 file changed, 4 deletions(-)
Applied. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH BlueZ 3/3] core: Attach and detach object manager
From: Luiz Augusto von Dentz @ 2012-11-29 13:39 UTC (permalink / raw)
To: Lucas De Marchi; +Cc: linux-bluetooth@vger.kernel.org, Lucas De Marchi
In-Reply-To: <1354195173-12750-3-git-send-email-lucas.demarchi@profusion.mobi>
Hi Lucas,
On Thu, Nov 29, 2012 at 3:19 PM, Lucas De Marchi
<lucas.demarchi@profusion.mobi> wrote:
> From: Lucas De Marchi <lucas.de.marchi@gmail.com>
>
> ---
> src/main.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/src/main.c b/src/main.c
> index 414849a..ccb5fa5 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -381,6 +381,7 @@ static void disconnect_dbus(void)
> if (!conn || !dbus_connection_get_is_connected(conn))
> return;
>
> + g_dbus_detach_object_manager(conn);
> set_dbus_connection(NULL);
>
> dbus_connection_unref(conn);
> @@ -412,6 +413,7 @@ static int connect_dbus(void)
> set_dbus_connection(conn);
>
> g_dbus_set_disconnect_function(conn, disconnected_dbus, NULL, NULL);
> + g_dbus_attach_object_manager(conn);
>
> return 0;
> }
> --
> 1.8.0.1
Ack.
--
Luiz Augusto von Dentz
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox