* [PATCH] android: Fix NULL pointer dereference
@ 2014-03-31 12:45 Marcin Kraglak
2014-03-31 13:54 ` Szymon Janc
0 siblings, 1 reply; 2+ messages in thread
From: Marcin Kraglak @ 2014-03-31 12:45 UTC (permalink / raw)
To: linux-bluetooth
If there is no adapter, hal_ipc in not initialized. Below is
message from valgrind:
==22501== Invalid read of size 4
==22501== at 0x805B809: ipc_unregister (ipc.c:421)
==22501== by 0x804AEAF: main (main.c:548)
==22501== Address 0x4 is not stack'd, malloc'd or (recently) free'd
---
android/main.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/android/main.c b/android/main.c
index 828f81d..e229a6d 100644
--- a/android/main.c
+++ b/android/main.c
@@ -541,8 +541,11 @@ int main(int argc, char *argv[])
bt_bluetooth_cleanup();
g_main_loop_unref(event_loop);
- ipc_unregister(hal_ipc, HAL_SERVICE_ID_CORE);
- ipc_cleanup(hal_ipc);
+ /* If no adapter was initialized, hal_ipc is NULL */
+ if (hal_ipc) {
+ ipc_unregister(hal_ipc, HAL_SERVICE_ID_CORE);
+ ipc_cleanup(hal_ipc);
+ }
info("Exit");
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] android: Fix NULL pointer dereference
2014-03-31 12:45 [PATCH] android: Fix NULL pointer dereference Marcin Kraglak
@ 2014-03-31 13:54 ` Szymon Janc
0 siblings, 0 replies; 2+ messages in thread
From: Szymon Janc @ 2014-03-31 13:54 UTC (permalink / raw)
To: Marcin Kraglak; +Cc: linux-bluetooth
Hi Marcin,
On Monday 31 of March 2014 14:45:13 Marcin Kraglak wrote:
> If there is no adapter, hal_ipc in not initialized. Below is
> message from valgrind:
>
> ==22501== Invalid read of size 4
> ==22501== at 0x805B809: ipc_unregister (ipc.c:421)
> ==22501== by 0x804AEAF: main (main.c:548)
> ==22501== Address 0x4 is not stack'd, malloc'd or (recently) free'd
> ---
> android/main.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/android/main.c b/android/main.c
> index 828f81d..e229a6d 100644
> --- a/android/main.c
> +++ b/android/main.c
> @@ -541,8 +541,11 @@ int main(int argc, char *argv[])
> bt_bluetooth_cleanup();
> g_main_loop_unref(event_loop);
>
> - ipc_unregister(hal_ipc, HAL_SERVICE_ID_CORE);
> - ipc_cleanup(hal_ipc);
> + /* If no adapter was initialized, hal_ipc is NULL */
> + if (hal_ipc) {
> + ipc_unregister(hal_ipc, HAL_SERVICE_ID_CORE);
> + ipc_cleanup(hal_ipc);
> + }
>
> info("Exit");
Applied, thanks.
--
Best regards,
Szymon Janc
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-03-31 13:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-31 12:45 [PATCH] android: Fix NULL pointer dereference Marcin Kraglak
2014-03-31 13:54 ` Szymon Janc
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).