All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] android/hal-bluetooth: Fix NULL ptr dereference
@ 2015-06-29  6:44 Atul Rai
  2015-07-27 19:21 ` Szymon Janc
  0 siblings, 1 reply; 4+ messages in thread
From: Atul Rai @ 2015-06-29  6:44 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: sachin.dev

Add NULL check on malloc return to fix NULL pointer dereference
in case malloc fails.
---
 android/hal-bluetooth.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index e24f7d2..66f4a37 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -19,6 +19,7 @@
 #include <stdlib.h>
 #include <stdbool.h>
 #include <string.h>
+#include <errno.h>
 
 #include <cutils/properties.h>
 
@@ -1103,6 +1104,11 @@ static int open_bluetooth(const struct hw_module_t *module, char const *name,
 
 	DBG("");
 
+	if (!dev) {
+		error("Failed to allocate memory for device");
+		return -ENOMEM;
+	}
+
 	memset(dev, 0, sizeof(bluetooth_device_t));
 	dev->common.tag = HARDWARE_DEVICE_TAG;
 	dev->common.version = 0;
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] android/hal-bluetooth: Fix NULL ptr dereference
  2015-06-29  6:44 [PATCH] android/hal-bluetooth: Fix NULL ptr dereference Atul Rai
@ 2015-07-27 19:21 ` Szymon Janc
  0 siblings, 0 replies; 4+ messages in thread
From: Szymon Janc @ 2015-07-27 19:21 UTC (permalink / raw)
  To: Atul Rai; +Cc: linux-bluetooth, sachin.dev

Hi Atul,

On Monday 29 of June 2015 12:14:13 Atul Rai wrote:
> Add NULL check on malloc return to fix NULL pointer dereference
> in case malloc fails.
> ---
>  android/hal-bluetooth.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
> index e24f7d2..66f4a37 100644
> --- a/android/hal-bluetooth.c
> +++ b/android/hal-bluetooth.c
> @@ -19,6 +19,7 @@
>  #include <stdlib.h>
>  #include <stdbool.h>
>  #include <string.h>
> +#include <errno.h>
> 
>  #include <cutils/properties.h>
> 
> @@ -1103,6 +1104,11 @@ static int open_bluetooth(const struct hw_module_t
> *module, char const *name,
> 
>  	DBG("");
> 
> +	if (!dev) {
> +		error("Failed to allocate memory for device");
> +		return -ENOMEM;
> +	}
> +
>  	memset(dev, 0, sizeof(bluetooth_device_t));
>  	dev->common.tag = HARDWARE_DEVICE_TAG;
>  	dev->common.version = 0;

Patch applied, thanks.

-- 
BR
Szymon Janc

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] android/hal-bluetooth: Fix NULL ptr dereference
  2015-07-22  9:05 Atul Rai
@ 2015-07-24 17:38 ` Vinicius Costa Gomes
  0 siblings, 0 replies; 4+ messages in thread
From: Vinicius Costa Gomes @ 2015-07-24 17:38 UTC (permalink / raw)
  To: Atul Rai, linux-bluetooth; +Cc: sachin.dev

Hi,

Atul Rai <a.rai@samsung.com> writes:

> ping
>

I didn't get the original email.


>> ------- Original Message -------
>> Sender : Atul Kumar Rai<a.rai@samsung.com> Lead Engineer (1)/SRI-Delhi-SWC Group/Samsung Electronics
>> Date : Jun 29, 2015 12:14 (GMT+05:30)
>> Title : [PATCH] android/hal-bluetooth: Fix NULL ptr dereference
>>
>> Add NULL check on malloc return to fix NULL pointer dereference
>> in case malloc fails.
>> ---
>>  android/hal-bluetooth.c | 6 ++++++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
>> index e24f7d2..66f4a37 100644
>> --- a/android/hal-bluetooth.c
>> +++ b/android/hal-bluetooth.c
>> @@ -19,6 +19,7 @@
>>  #include <stdlib.h>
>>  #include <stdbool.h>
>>  #include <string.h>
>> +#include <errno.h>
>>
>>  #include <cutils/properties.h>
>>
>> @@ -1103,6 +1104,11 @@ static int open_bluetooth(const struct hw_module_t *module, char const *name,
>>
>>  	DBG("");
>>
>> +	if (!dev) {
>> +		error("Failed to allocate memory for device");
>> +		return -ENOMEM;
>> +	}
>> +

Looks OK. Just wondering why it is not using calloc() instead of
'malloc() + sizeof()'.


Cheers,
--
Vinicius

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] android/hal-bluetooth: Fix NULL ptr dereference
@ 2015-07-22  9:05 Atul Rai
  2015-07-24 17:38 ` Vinicius Costa Gomes
  0 siblings, 1 reply; 4+ messages in thread
From: Atul Rai @ 2015-07-22  9:05 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: sachin.dev

ping

> ------- Original Message -------
> Sender : Atul Kumar Rai<a.rai@samsung.com> Lead Engineer (1)/SRI-Delhi-SWC Group/Samsung Electronics
> Date : Jun 29, 2015 12:14 (GMT+05:30)
> Title : [PATCH] android/hal-bluetooth: Fix NULL ptr dereference
>
> Add NULL check on malloc return to fix NULL pointer dereference
> in case malloc fails.
> ---
>  android/hal-bluetooth.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
> index e24f7d2..66f4a37 100644
> --- a/android/hal-bluetooth.c
> +++ b/android/hal-bluetooth.c
> @@ -19,6 +19,7 @@
>  #include <stdlib.h>
>  #include <stdbool.h>
>  #include <string.h>
> +#include <errno.h>
>  
>  #include <cutils/properties.h>
>  
> @@ -1103,6 +1104,11 @@ static int open_bluetooth(const struct hw_module_t *module, char const *name,
>  
>  	DBG("");
>  
> +	if (!dev) {
> +		error("Failed to allocate memory for device");
> +		return -ENOMEM;
> +	}
> +
>  	memset(dev, 0, sizeof(bluetooth_device_t));
>  	dev->common.tag = HARDWARE_DEVICE_TAG;
>  	dev->common.version = 0;
> -- 
> 2.1.4
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-07-27 19:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-29  6:44 [PATCH] android/hal-bluetooth: Fix NULL ptr dereference Atul Rai
2015-07-27 19:21 ` Szymon Janc
2015-07-22  9:05 Atul Rai
2015-07-24 17:38 ` Vinicius Costa Gomes

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.