* [PATCH] tools/hciconfig:Fixed Memory Leak
@ 2015-07-27 9:36 Anchit Narang
2015-07-27 10:07 ` Szymon Janc
0 siblings, 1 reply; 2+ messages in thread
From: Anchit Narang @ 2015-07-27 9:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: sachin.dev
Freed memory allocated to structure hci_dev_list_req to avoid memory leak
---
tools/hciconfig.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tools/hciconfig.c b/tools/hciconfig.c
index 6397e71..0738b53 100644
--- a/tools/hciconfig.c
+++ b/tools/hciconfig.c
@@ -69,6 +69,10 @@ static void print_dev_list(int ctl, int flags)
if (ioctl(ctl, HCIGETDEVLIST, (void *) dl) < 0) {
perror("Can't get device list");
+
+ if (dl)
+ free(dl);
+
exit(1);
}
@@ -78,6 +82,9 @@ static void print_dev_list(int ctl, int flags)
continue;
print_dev_info(ctl, &di);
}
+
+ if (dl)
+ free(dl);
}
static void print_pkt_type(struct hci_dev_info *di)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] tools/hciconfig:Fixed Memory Leak
2015-07-27 9:36 [PATCH] tools/hciconfig:Fixed Memory Leak Anchit Narang
@ 2015-07-27 10:07 ` Szymon Janc
0 siblings, 0 replies; 2+ messages in thread
From: Szymon Janc @ 2015-07-27 10:07 UTC (permalink / raw)
To: Anchit Narang; +Cc: linux-bluetooth, sachin.dev
Hi Anchit,
On Monday 27 of July 2015 15:06:39 Anchit Narang wrote:
> Freed memory allocated to structure hci_dev_list_req to avoid memory leak
> ---
> tools/hciconfig.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/tools/hciconfig.c b/tools/hciconfig.c
> index 6397e71..0738b53 100644
> --- a/tools/hciconfig.c
> +++ b/tools/hciconfig.c
> @@ -69,6 +69,10 @@ static void print_dev_list(int ctl, int flags)
>
> if (ioctl(ctl, HCIGETDEVLIST, (void *) dl) < 0) {
> perror("Can't get device list");
> +
> + if (dl)
> + free(dl);
> +
There is no need to check for non-NULL pointer as free() handles this
internally.
> exit(1);
> }
>
> @@ -78,6 +82,9 @@ static void print_dev_list(int ctl, int flags)
> continue;
> print_dev_info(ctl, &di);
> }
> +
> + if (dl)
> + free(dl);
Same here.
> }
>
> static void print_pkt_type(struct hci_dev_info *di)
--
BR
Szymon Janc
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-07-27 10:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-27 9:36 [PATCH] tools/hciconfig:Fixed Memory Leak Anchit Narang
2015-07-27 10:07 ` Szymon Janc
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.