* [PATCH] Fix a memory leak, all dir opened with opendir must be closed with closedir
@ 2011-05-11 15:27 Bertrand Aygon
2011-05-11 18:35 ` Denis Kenzior
0 siblings, 1 reply; 2+ messages in thread
From: Bertrand Aygon @ 2011-05-11 15:27 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1521 bytes --]
---
plugins/nokia-gpio.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/plugins/nokia-gpio.c b/plugins/nokia-gpio.c
index 3ddf6e1..57aad8d 100644
--- a/plugins/nokia-gpio.c
+++ b/plugins/nokia-gpio.c
@@ -645,7 +645,6 @@ static int gpio_probe_links(void)
DBG("Using %s: trying to make links to %s", gpiodir, cmtdir);
if (!dir_exists(cmtdir)) {
-
if (mkdir(cmtdir, 0755) == -1) {
DBG("%s: %s", cmtdir, strerror(errno));
return -(errno = ENODEV);
@@ -663,8 +662,10 @@ static int gpio_probe_links(void)
FILE *nf;
size_t len;
- if (d == NULL)
+ if (d == NULL) {
+ (void) closedir(gpio);
return 0;
+ }
snprintf(nn, sizeof nn, "%s/%s/name", gpiodir, d->d_name);
@@ -701,6 +702,8 @@ static int gpio_probe_links(void)
DBG("%s: %s", "/sys/class/gpio", strerror(errno));
+ (void) closedir(gpio);
+
return -(errno = ENODEV);
}
--
1.7.4.1
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number: 302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] Fix a memory leak, all dir opened with opendir must be closed with closedir
2011-05-11 15:27 [PATCH] Fix a memory leak, all dir opened with opendir must be closed with closedir Bertrand Aygon
@ 2011-05-11 18:35 ` Denis Kenzior
0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2011-05-11 18:35 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1227 bytes --]
Hi Bertrand,
On 05/11/2011 10:27 AM, Bertrand Aygon wrote:
> ---
> plugins/nokia-gpio.c | 7 +++++--
> 1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/plugins/nokia-gpio.c b/plugins/nokia-gpio.c
> index 3ddf6e1..57aad8d 100644
> --- a/plugins/nokia-gpio.c
> +++ b/plugins/nokia-gpio.c
> @@ -645,7 +645,6 @@ static int gpio_probe_links(void)
> DBG("Using %s: trying to make links to %s", gpiodir, cmtdir);
>
> if (!dir_exists(cmtdir)) {
> -
> if (mkdir(cmtdir, 0755) == -1) {
> DBG("%s: %s", cmtdir, strerror(errno));
> return -(errno = ENODEV);
Since this is a style issue, I broke your patch up into two.
> @@ -663,8 +662,10 @@ static int gpio_probe_links(void)
> FILE *nf;
> size_t len;
>
> - if (d == NULL)
> + if (d == NULL) {
> + (void) closedir(gpio);
> return 0;
> + }
>
> snprintf(nn, sizeof nn, "%s/%s/name", gpiodir, d->d_name);
>
> @@ -701,6 +702,8 @@ static int gpio_probe_links(void)
>
> DBG("%s: %s", "/sys/class/gpio", strerror(errno));
>
> + (void) closedir(gpio);
> +
> return -(errno = ENODEV);
> }
>
Patch has been applied with a modified commit message. Thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-05-11 18:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-11 15:27 [PATCH] Fix a memory leak, all dir opened with opendir must be closed with closedir Bertrand Aygon
2011-05-11 18:35 ` Denis Kenzior
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.