linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] android/client/if-hl.c:Handle failure from malloc() request
@ 2015-07-21 13:38 Anupam Roy
  2015-07-27 19:22 ` Szymon Janc
  0 siblings, 1 reply; 5+ messages in thread
From: Anupam Roy @ 2015-07-21 13:38 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: sachin.dev

In case malloc() request fails, just print error message
and return. Dereferencing reg.mdep_cfg in case of failure
can lead to crash.
---
 android/client/if-hl.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/android/client/if-hl.c b/android/client/if-hl.c
index e0818ba..bd05671 100644
--- a/android/client/if-hl.c
+++ b/android/client/if-hl.c
@@ -201,6 +201,10 @@ static void register_application_p(int argc, const char **argv)
 	reg.number_of_mdeps = atoi(argv[6]);
 
 	reg.mdep_cfg = malloc(reg.number_of_mdeps * sizeof(bthl_mdep_cfg_t));
+	if (!reg.mdep_cfg) {
+		haltest_error("malloc failed\n");
+		return;
+	}
 	mdep_argc_init = 7;
 
 	for (i = 0; i < reg.number_of_mdeps; i++) {
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread
* RE: [PATCH] android/client/if-hl.c:Handle failure from malloc() request
@ 2015-07-21 13:01 Anupam Roy
  2015-07-21 13:22 ` Szymon Janc
  0 siblings, 1 reply; 5+ messages in thread
From: Anupam Roy @ 2015-07-21 13:01 UTC (permalink / raw)
  To: linux-bluetooth

Ping

> -----Original Message-----
>From: Anupam Roy <anupam.r@samsung.com>
>To: linux-bluetooth@vger.kernel.org
>Cc:sachin.dev@samsung.com; anupam.r@samsung.com
>Date : Jun 23, 2015 21:04 (GMT+09:00)
>Title : [PATCH] android/client/if-hl.c:Handle failure from malloc() request
>
>
>In case malloc() request fails, just print error message
>and return. Dereferencing reg.mdep_cfg in case of failure
>can lead to crash.
>---
> android/client/if-hl.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
>diff --git a/android/client/if-hl.c b/android/client/if-hl.c
>index e0818ba..bd05671 100644
>--- a/android/client/if-hl.c
>+++ b/android/client/if-hl.c
>@@ -201,6 +201,10 @@ static void register_application_p(int argc, const char **argv)
> 	reg.number_of_mdeps = atoi(argv[6]);
> 
> 	reg.mdep_cfg = malloc(reg.number_of_mdeps * sizeof(bthl_mdep_cfg_t));
>+	if (!reg.mdep_cfg) {
>+		haltest_error("malloc failed\n");
>+		return;
>+	}
> 	mdep_argc_init = 7;
> 
> 	for (i = 0; i < reg.number_of_mdeps; i++) {
>-- 
>1.9.1


^ permalink raw reply	[flat|nested] 5+ messages in thread
* [PATCH] android/client/if-hl.c:Handle failure from malloc() request
@ 2015-06-23 12:04 Anupam Roy
  0 siblings, 0 replies; 5+ messages in thread
From: Anupam Roy @ 2015-06-23 12:04 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: sachin.dev, Anupam Roy

In case malloc() request fails, just print error message
and return. Dereferencing reg.mdep_cfg in case of failure
can lead to crash.
---
 android/client/if-hl.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/android/client/if-hl.c b/android/client/if-hl.c
index e0818ba..bd05671 100644
--- a/android/client/if-hl.c
+++ b/android/client/if-hl.c
@@ -201,6 +201,10 @@ static void register_application_p(int argc, const char **argv)
 	reg.number_of_mdeps = atoi(argv[6]);
 
 	reg.mdep_cfg = malloc(reg.number_of_mdeps * sizeof(bthl_mdep_cfg_t));
+	if (!reg.mdep_cfg) {
+		haltest_error("malloc failed\n");
+		return;
+	}
 	mdep_argc_init = 7;
 
 	for (i = 0; i < reg.number_of_mdeps; i++) {
-- 
1.9.1


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

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

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-21 13:38 [PATCH] android/client/if-hl.c:Handle failure from malloc() request Anupam Roy
2015-07-27 19:22 ` Szymon Janc
  -- strict thread matches above, loose matches on Subject: below --
2015-07-21 13:01 Anupam Roy
2015-07-21 13:22 ` Szymon Janc
2015-06-23 12:04 Anupam Roy

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).