2014-02-07 12:11:15

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 1/4] android/haltest: Remove unneeded assignment

From: Andrei Emeltchenko <[email protected]>

---
android/client/if-audio.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/android/client/if-audio.c b/android/client/if-audio.c
index 8c640a1..5ab11a6 100644
--- a/android/client/if-audio.c
+++ b/android/client/if-audio.c
@@ -225,10 +225,8 @@ static void *playback_thread(void *data)
pthread_mutex_unlock(&outstream_mutex);
} while (len && w_len > 0);

- if (in) {
+ if (in)
fclose(in);
- in = NULL;
- }

pthread_cleanup_pop(1);
return NULL;
--
1.8.3.2



2014-02-13 08:21:32

by Andrei Emeltchenko

[permalink] [raw]
Subject: Re: [PATCH 1/4] android/haltest: Remove unneeded assignment

Hi Luiz,

On Mon, Feb 10, 2014 at 02:16:09PM +0200, Luiz Augusto von Dentz wrote:
> Hi Andrei,
>
> On Fri, Feb 7, 2014 at 2:11 PM, Andrei Emeltchenko
> <[email protected]> wrote:
> > From: Andrei Emeltchenko <[email protected]>
> >
> > ---
> > android/client/if-audio.c | 4 +---
> > 1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/android/client/if-audio.c b/android/client/if-audio.c
> > index 8c640a1..5ab11a6 100644
> > --- a/android/client/if-audio.c
> > +++ b/android/client/if-audio.c
> > @@ -225,10 +225,8 @@ static void *playback_thread(void *data)
> > pthread_mutex_unlock(&outstream_mutex);
> > } while (len && w_len > 0);
> >
> > - if (in) {
> > + if (in)
> > fclose(in);
> > - in = NULL;
> > - }
> >
> > pthread_cleanup_pop(1);
> > return NULL;
> > --
> > 1.8.3.2
>
> Pushed, note that I did move the changes from audio to android since
> the audio code will be dropped as it is not unit tested.

I still think that those patches needs to applied otherwise we have
following warnings:

...
CC profiles/audio/bluetoothd-avdtp.o
profiles/audio/avdtp.c:2735:2: warning: Null pointer passed as an argument
to a 'nonnull' parameter
memcpy(req->data, buffer, size);
^ ~~~~~~
profiles/audio/avdtp.c:3290:2: warning: Null pointer passed as an argument
to a 'nonnull' parameter
memcpy(cap->data, data, length);
^ ~~~~
2 warnings generated.
...

You may choose to fix those warns other ways though.

Best regards
Andrei Emeltchenko


2014-02-10 12:16:09

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH 1/4] android/haltest: Remove unneeded assignment

Hi Andrei,

On Fri, Feb 7, 2014 at 2:11 PM, Andrei Emeltchenko
<[email protected]> wrote:
> From: Andrei Emeltchenko <[email protected]>
>
> ---
> android/client/if-audio.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/android/client/if-audio.c b/android/client/if-audio.c
> index 8c640a1..5ab11a6 100644
> --- a/android/client/if-audio.c
> +++ b/android/client/if-audio.c
> @@ -225,10 +225,8 @@ static void *playback_thread(void *data)
> pthread_mutex_unlock(&outstream_mutex);
> } while (len && w_len > 0);
>
> - if (in) {
> + if (in)
> fclose(in);
> - in = NULL;
> - }
>
> pthread_cleanup_pop(1);
> return NULL;
> --
> 1.8.3.2

Pushed, note that I did move the changes from audio to android since
the audio code will be dropped as it is not unit tested.


--
Luiz Augusto von Dentz

2014-02-07 12:11:16

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 2/4] avdtp: Fix passing NULL pointer to memcpy

From: Andrei Emeltchenko <[email protected]>

send_request can be called as
send_request(session, FALSE, NULL, AVDTP_DISCOVER, NULL, 0) with NULL
pointer which is passed to memcpy().
---
profiles/audio/avdtp.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index fbf61f0..da10ab4 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -2731,11 +2731,14 @@ static int send_request(struct avdtp *session, gboolean priority,

req = g_new0(struct pending_req, 1);
req->signal_id = signal_id;
- req->data = g_malloc(size);
- memcpy(req->data, buffer, size);
- req->data_size = size;
req->stream = stream;

+ if (buffer && size) {
+ req->data = g_malloc(size);
+ memcpy(req->data, buffer, size);
+ req->data_size = size;
+ }
+
return send_req(session, priority, req);
}

--
1.8.3.2


2014-02-07 12:11:17

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 3/4] avdtp: Fix passing NULL pointer to memcpy

From: Andrei Emeltchenko <[email protected]>

The patch fixes following clang warning:
...
profiles/audio/avdtp.c:3293:2: warning: Null pointer passed as an
argument to a 'nonnull' parameter
memcpy(cap->data, data, length);
^ ~~~~
1 warning generated.
...
---
profiles/audio/avdtp.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index da10ab4..b7ddb6c 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -3290,7 +3290,9 @@ struct avdtp_service_capability *avdtp_service_cap_new(uint8_t category,
cap = g_malloc(sizeof(struct avdtp_service_capability) + length);
cap->category = category;
cap->length = length;
- memcpy(cap->data, data, length);
+
+ if (data)
+ memcpy(cap->data, data, length);

return cap;
}
--
1.8.3.2


2014-02-07 12:11:18

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 4/4] bnep: Calculate ifindex after NULL check

From: Andrei Emeltchenko <[email protected]>

---
profiles/network/bnep.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/profiles/network/bnep.c b/profiles/network/bnep.c
index 1aa0783..ece979f 100644
--- a/profiles/network/bnep.c
+++ b/profiles/network/bnep.c
@@ -523,13 +523,15 @@ static int bnep_add_to_bridge(const char *devname, const char *bridge)

static int bnep_del_from_bridge(const char *devname, const char *bridge)
{
- int ifindex = if_nametoindex(devname);
+ int ifindex;
struct ifreq ifr;
int sk, err;

if (!devname || !bridge)
return -EINVAL;

+ ifindex = if_nametoindex(devname);
+
sk = socket(AF_INET, SOCK_STREAM, 0);
if (sk < 0)
return -1;
--
1.8.3.2