2015-07-21 13:38:01

by Anupam Roy

[permalink] [raw]
Subject: [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



2015-07-21 13:22:01

by Szymon Janc

[permalink] [raw]
Subject: Re: [PATCH] android/client/if-hl.c:Handle failure from malloc() request

Hi Anupam,

On Tuesday 21 of July 2015 09:01:17 Anupam Roy wrote:
> Ping

I looks like I never got the original patch. Could you resend it?
(seems like you hit timeframe when my gmail was experiencing issues with vger
server and I had to resubscribe to mailing list)

> > -----Original Message-----
> >
> >From: Anupam Roy <[email protected]>
> >To: [email protected]
> >Cc:[email protected]; [email protected]
> >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++) {
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth"
> in the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

--
BR
Szymon Janc

2015-07-21 13:01:17

by Anupam Roy

[permalink] [raw]
Subject: RE: [PATCH] android/client/if-hl.c:Handle failure from malloc() request

Ping

> -----Original Message-----
>From: Anupam Roy <[email protected]>
>To: [email protected]
>Cc:[email protected]; [email protected]
>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