* [PATCH 1/2] shared/gatt: Fix dereference before NULL check warnings
@ 2014-11-20 13:13 Andrei Emeltchenko
2014-11-20 13:13 ` [PATCH 2/2] tools/gatt: Fix memory leak Andrei Emeltchenko
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Andrei Emeltchenko @ 2014-11-20 13:13 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Add NULL check otherwise constructions like below give warnings:
...
uint8_t pdu[4 + get_uuid_len(uuid)];
if (!att || !uuid || uuid->type == BT_UUID_UNSPEC)
...
---
src/shared/gatt-helpers.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/shared/gatt-helpers.c b/src/shared/gatt-helpers.c
index d0bee3f..dc4a8e8 100644
--- a/src/shared/gatt-helpers.c
+++ b/src/shared/gatt-helpers.c
@@ -588,6 +588,9 @@ static void put_uuid_le(const bt_uuid_t *src, void *dst)
static inline int get_uuid_len(const bt_uuid_t *uuid)
{
+ if (!uuid)
+ return 0;
+
return (uuid->type == BT_UUID16) ? 2 : 16;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] tools/gatt: Fix memory leak
2014-11-20 13:13 [PATCH 1/2] shared/gatt: Fix dereference before NULL check warnings Andrei Emeltchenko
@ 2014-11-20 13:13 ` Andrei Emeltchenko
2014-11-27 9:04 ` [PATCH 1/2] shared/gatt: Fix dereference before NULL check warnings Andrei Emeltchenko
2014-11-27 12:58 ` Johan Hedberg
2 siblings, 0 replies; 4+ messages in thread
From: Andrei Emeltchenko @ 2014-11-20 13:13 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Fixes following clang warning:
...
tools/btgatt-client.c:451:4: warning: Potential leak of memory pointed
to by 'value'
printf("Invalid value byte: %s\n", argv[i]);
^~~~~~
...
---
tools/btgatt-client.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/btgatt-client.c b/tools/btgatt-client.c
index ca84780..dadfa37 100644
--- a/tools/btgatt-client.c
+++ b/tools/btgatt-client.c
@@ -449,6 +449,7 @@ static void cmd_read_multiple(struct client *cli, char *cmd_str)
value[i] = strtol(argv[i], &endptr, 0);
if (endptr == argv[i] || *endptr != '\0' || !value[i]) {
printf("Invalid value byte: %s\n", argv[i]);
+ free(value);
return;
}
}
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] shared/gatt: Fix dereference before NULL check warnings
2014-11-20 13:13 [PATCH 1/2] shared/gatt: Fix dereference before NULL check warnings Andrei Emeltchenko
2014-11-20 13:13 ` [PATCH 2/2] tools/gatt: Fix memory leak Andrei Emeltchenko
@ 2014-11-27 9:04 ` Andrei Emeltchenko
2014-11-27 12:58 ` Johan Hedberg
2 siblings, 0 replies; 4+ messages in thread
From: Andrei Emeltchenko @ 2014-11-27 9:04 UTC (permalink / raw)
To: linux-bluetooth
ping
On Thu, Nov 20, 2014 at 03:13:14PM +0200, Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> Add NULL check otherwise constructions like below give warnings:
> ...
> uint8_t pdu[4 + get_uuid_len(uuid)];
>
> if (!att || !uuid || uuid->type == BT_UUID_UNSPEC)
> ...
> ---
> src/shared/gatt-helpers.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/src/shared/gatt-helpers.c b/src/shared/gatt-helpers.c
> index d0bee3f..dc4a8e8 100644
> --- a/src/shared/gatt-helpers.c
> +++ b/src/shared/gatt-helpers.c
> @@ -588,6 +588,9 @@ static void put_uuid_le(const bt_uuid_t *src, void *dst)
>
> static inline int get_uuid_len(const bt_uuid_t *uuid)
> {
> + if (!uuid)
> + return 0;
> +
> return (uuid->type == BT_UUID16) ? 2 : 16;
> }
>
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] shared/gatt: Fix dereference before NULL check warnings
2014-11-20 13:13 [PATCH 1/2] shared/gatt: Fix dereference before NULL check warnings Andrei Emeltchenko
2014-11-20 13:13 ` [PATCH 2/2] tools/gatt: Fix memory leak Andrei Emeltchenko
2014-11-27 9:04 ` [PATCH 1/2] shared/gatt: Fix dereference before NULL check warnings Andrei Emeltchenko
@ 2014-11-27 12:58 ` Johan Hedberg
2 siblings, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2014-11-27 12:58 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
Hi Andrei,
On Thu, Nov 20, 2014, Andrei Emeltchenko wrote:
> Add NULL check otherwise constructions like below give warnings:
> ...
> uint8_t pdu[4 + get_uuid_len(uuid)];
>
> if (!att || !uuid || uuid->type == BT_UUID_UNSPEC)
> ...
> ---
> src/shared/gatt-helpers.c | 3 +++
> 1 file changed, 3 insertions(+)
Both patches in this set have been applied. Thanks.
Johan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-11-27 12:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-20 13:13 [PATCH 1/2] shared/gatt: Fix dereference before NULL check warnings Andrei Emeltchenko
2014-11-20 13:13 ` [PATCH 2/2] tools/gatt: Fix memory leak Andrei Emeltchenko
2014-11-27 9:04 ` [PATCH 1/2] shared/gatt: Fix dereference before NULL check warnings Andrei Emeltchenko
2014-11-27 12:58 ` Johan Hedberg
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).