2011-08-16 09:49:02

by Pavel Raiskup

[permalink] [raw]
Subject: [PATCH 5/8] Added NULL check before dereferencing

---
plugins/hciops.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/plugins/hciops.c b/plugins/hciops.c
index ecc0e86..e975eb5 100644
--- a/plugins/hciops.c
+++ b/plugins/hciops.c
@@ -593,7 +593,8 @@ static gboolean init_adapter(int index)
} else {
adapter = manager_find_adapter(&dev->bdaddr);
/* FIXME: manager_find_adapter should return a new ref */
- btd_adapter_ref(adapter);
+ if (adapter)
+ btd_adapter_ref(adapter);
}

if (adapter == NULL)
--
1.7.4.4


2011-08-30 13:11:54

by Pavel Raiskup

[permalink] [raw]
Subject: [PATCH 5/8] Added NULL check before dereferencing

---
plugins/hciops.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/plugins/hciops.c b/plugins/hciops.c
index ecc0e86..e975eb5 100644
--- a/plugins/hciops.c
+++ b/plugins/hciops.c
@@ -593,7 +593,8 @@ static gboolean init_adapter(int index)
} else {
adapter = manager_find_adapter(&dev->bdaddr);
/* FIXME: manager_find_adapter should return a new ref */
- btd_adapter_ref(adapter);
+ if (adapter)
+ btd_adapter_ref(adapter);
}

if (adapter == NULL)
--
1.7.4.4


2011-08-17 08:45:05

by Pavel Raiskup

[permalink] [raw]
Subject: Re: [PATCH 5/8] Added NULL check before dereferencing

Hi Luiz,

> On Tue, Aug 16, 2011 at 12:49 PM, Pavel Raiskup <[email protected]>
> wrote:
>> ---
>> plugins/hciops.c | 3 ++-
>> 1 files changed, 2 insertions(+), 1 deletions(-)
>>
>> diff --git a/plugins/hciops.c b/plugins/hciops.c
>> index ecc0e86..e975eb5 100644
>> --- a/plugins/hciops.c
>> +++ b/plugins/hciops.c
>> @@ -593,7 +593,8 @@ static gboolean init_adapter(int index)
>> } else {
>> adapter = manager_find_adapter(&dev->bdaddr);
>> /* FIXME: manager_find_adapter should return a new ref */
>> - btd_adapter_ref(adapter);
>> + if (adapter)
>> + btd_adapter_ref(adapter);
>
> Perhaps we should either make manager_find_adapter to return a new ref
> or create a function e.g. manager_get_adapter which does that for us.

actually, I don't have as good experiences (and time now) for such
improvements.
This patch has not removed "FIXME"! -- it was thought like null deref.
prevention
patch only.

Pavel

2011-08-16 10:31:57

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH 5/8] Added NULL check before dereferencing

Hi Pavel,

On Tue, Aug 16, 2011 at 12:49 PM, Pavel Raiskup <[email protected]> wrote:
> ---
> ?plugins/hciops.c | ? ?3 ++-
> ?1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/plugins/hciops.c b/plugins/hciops.c
> index ecc0e86..e975eb5 100644
> --- a/plugins/hciops.c
> +++ b/plugins/hciops.c
> @@ -593,7 +593,8 @@ static gboolean init_adapter(int index)
> ? ? ? ?} else {
> ? ? ? ? ? ? ? ?adapter = manager_find_adapter(&dev->bdaddr);
> ? ? ? ? ? ? ? ?/* FIXME: manager_find_adapter should return a new ref */
> - ? ? ? ? ? ? ? btd_adapter_ref(adapter);
> + ? ? ? ? ? ? ? if (adapter)
> + ? ? ? ? ? ? ? ? ? ? ? btd_adapter_ref(adapter);

Perhaps we should either make manager_find_adapter to return a new ref
or create a function e.g. manager_get_adapter which does that for us.

--
Luiz Augusto von Dentz