diff options
author | Steve Grubb <sgrubb@redhat.com> | 2009-09-25 16:23:02 -0400 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2009-10-02 11:18:16 +0200 |
commit | 2e926fb0168ba0249dfbbcca71ff685e4235e1c7 (patch) | |
tree | 6113833bd98ccc40d16740fc2d4a9927990ef5c1 /compat | |
parent | 11091ffeeb39fd7a764925b3f146096c48b32407 (diff) |
Fix memory leaks
I was doing some code reviews of the 4.54 release and found a few memory
leaks. These are mostly in error paths.
Diffstat (limited to 'compat')
-rw-r--r-- | compat/dun.c | 1 | ||||
-rw-r--r-- | compat/dund.c | 9 | ||||
-rw-r--r-- | compat/pand.c | 12 |
3 files changed, 19 insertions, 3 deletions
diff --git a/compat/dun.c b/compat/dun.c index 7140bacd5..3d4dab4d5 100644 --- a/compat/dun.c +++ b/compat/dun.c @@ -86,6 +86,7 @@ static int for_each_port(int (*func)(struct rfcomm_dev_info *, unsigned long), u } close(sk); + free(dl); return r; } diff --git a/compat/dund.c b/compat/dund.c index fc8ba3036..f9847ea83 100644 --- a/compat/dund.c +++ b/compat/dund.c @@ -568,21 +568,26 @@ int main(int argc, char *argv[]) io_init(); - if (dun_init()) + if (dun_init()) { + free(dst); return -1; + } /* Check non daemon modes first */ switch (mode) { case SHOW: do_show(); + free(dst); return 0; case KILL: do_kill(dst); + free(dst); return 0; case NONE: printf(main_help, VERSION); + free(dst); return 0; } @@ -612,6 +617,7 @@ int main(int argc, char *argv[]) src_dev = hci_devid(src); if (src_dev < 0 || hci_devba(src_dev, &src_addr) < 0) { syslog(LOG_ERR, "Invalid source. %s(%d)", strerror(errno), errno); + free(dst); return -1; } } @@ -634,5 +640,6 @@ int main(int argc, char *argv[]) break; } + free(dst); return 0; } diff --git a/compat/pand.c b/compat/pand.c index c3f39333a..53f6c41d6 100644 --- a/compat/pand.c +++ b/compat/pand.c @@ -721,21 +721,26 @@ int main(int argc, char *argv[]) argv += optind; optind = 0; - if (bnep_init()) + if (bnep_init()) { + free(dst); return -1; + } /* Check non daemon modes first */ switch (mode) { case SHOW: do_show(); + free(dst); return 0; case KILL: do_kill(dst); + free(dst); return 0; case NONE: printf(main_help, VERSION); + free(dst); return 0; } @@ -766,12 +771,15 @@ int main(int argc, char *argv[]) if (src_dev < 0 || hci_devba(src_dev, &src_addr) < 0) { syslog(LOG_ERR, "Invalid source. %s(%d)", strerror(errno), errno); + free(dst); return -1; } } - if (pidfile && write_pidfile()) + if (pidfile && write_pidfile()) { + free(dst); return -1; + } if (dst) { /* Disable cache invalidation */ |