* [PATCH 1/3] iio staging: fix potential resource leak in generic_buffer
@ 2012-06-25 21:13 Peter Meerwald
2012-06-25 21:13 ` [PATCH 2/3] iio staging: fix potential memory/resource leaks in find_type_by_name() Peter Meerwald
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Peter Meerwald @ 2012-06-25 21:13 UTC (permalink / raw)
To: linux-iio; +Cc: jic23, Peter Meerwald
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
---
drivers/staging/iio/Documentation/iio_utils.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/iio/Documentation/iio_utils.h b/drivers/staging/iio/Documentation/iio_utils.h
index c0448b3..9241288 100644
--- a/drivers/staging/iio/Documentation/iio_utils.h
+++ b/drivers/staging/iio/Documentation/iio_utils.h
@@ -158,7 +158,8 @@ inline int iioutils_get_type(unsigned *is_signed,
&padint, shift);
if (ret < 0) {
printf("failed to pass scan type description\n");
- return ret;
+ ret = -errno;
+ goto error_close_sysfsfp;
}
*be = (endianchar == 'b');
*bytes = padint / 8;
@@ -174,7 +175,11 @@ inline int iioutils_get_type(unsigned *is_signed,
free(filename);
filename = 0;
+ sysfsfp = 0;
}
+error_close_sysfsfp:
+ if (sysfsfp)
+ fclose(sysfsfp);
error_free_filename:
if (filename)
free(filename);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/3] iio staging: fix potential memory/resource leaks in find_type_by_name()
2012-06-25 21:13 [PATCH 1/3] iio staging: fix potential resource leak in generic_buffer Peter Meerwald
@ 2012-06-25 21:13 ` Peter Meerwald
2012-06-25 21:13 ` [PATCH 3/3] iio staging: fix resource leak in _write_sysfs_int() Peter Meerwald
2012-06-30 12:41 ` [PATCH 1/3] iio staging: fix potential resource leak in generic_buffer Jonathan Cameron
2 siblings, 0 replies; 4+ messages in thread
From: Peter Meerwald @ 2012-06-25 21:13 UTC (permalink / raw)
To: linux-iio; +Cc: jic23, Peter Meerwald
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
---
drivers/staging/iio/Documentation/iio_utils.h | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/iio/Documentation/iio_utils.h b/drivers/staging/iio/Documentation/iio_utils.h
index 9241288..8869c55 100644
--- a/drivers/staging/iio/Documentation/iio_utils.h
+++ b/drivers/staging/iio/Documentation/iio_utils.h
@@ -473,23 +473,30 @@ inline int find_type_by_name(const char *name, const char *type)
+ strlen(type)
+ numstrlen
+ 6);
- if (filename == NULL)
+ if (filename == NULL) {
+ closedir(dp);
return -ENOMEM;
+ }
sprintf(filename, "%s%s%d/name",
iio_dir,
type,
number);
nameFile = fopen(filename, "r");
- if (!nameFile)
+ if (!nameFile) {
+ free(filename);
continue;
+ }
free(filename);
fscanf(nameFile, "%s", thisname);
- if (strcmp(name, thisname) == 0)
- return number;
fclose(nameFile);
+ if (strcmp(name, thisname) == 0) {
+ closedir(dp);
+ return number;
+ }
}
}
}
+ closedir(dp);
return -ENODEV;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 3/3] iio staging: fix resource leak in _write_sysfs_int()
2012-06-25 21:13 [PATCH 1/3] iio staging: fix potential resource leak in generic_buffer Peter Meerwald
2012-06-25 21:13 ` [PATCH 2/3] iio staging: fix potential memory/resource leaks in find_type_by_name() Peter Meerwald
@ 2012-06-25 21:13 ` Peter Meerwald
2012-06-30 12:41 ` [PATCH 1/3] iio staging: fix potential resource leak in generic_buffer Jonathan Cameron
2 siblings, 0 replies; 4+ messages in thread
From: Peter Meerwald @ 2012-06-25 21:13 UTC (permalink / raw)
To: linux-iio; +Cc: jic23, Peter Meerwald
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
---
drivers/staging/iio/Documentation/iio_utils.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/staging/iio/Documentation/iio_utils.h b/drivers/staging/iio/Documentation/iio_utils.h
index 8869c55..5244fa0 100644
--- a/drivers/staging/iio/Documentation/iio_utils.h
+++ b/drivers/staging/iio/Documentation/iio_utils.h
@@ -525,6 +525,7 @@ inline int _write_sysfs_int(char *filename, char *basedir, int val, int verify)
goto error_free;
}
fscanf(sysfsfp, "%d", &test);
+ fclose(sysfsfp);
if (test != val) {
printf("Possible failure in int write %d to %s%s\n",
val,
@@ -574,6 +575,7 @@ int _write_sysfs_string(char *filename, char *basedir, char *val, int verify)
goto error_free;
}
fscanf(sysfsfp, "%s", temp);
+ fclose(sysfsfp);
if (strcmp(temp, val) != 0) {
printf("Possible failure in string write of %s "
"Should be %s "
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 1/3] iio staging: fix potential resource leak in generic_buffer
2012-06-25 21:13 [PATCH 1/3] iio staging: fix potential resource leak in generic_buffer Peter Meerwald
2012-06-25 21:13 ` [PATCH 2/3] iio staging: fix potential memory/resource leaks in find_type_by_name() Peter Meerwald
2012-06-25 21:13 ` [PATCH 3/3] iio staging: fix resource leak in _write_sysfs_int() Peter Meerwald
@ 2012-06-30 12:41 ` Jonathan Cameron
2 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2012-06-30 12:41 UTC (permalink / raw)
To: Peter Meerwald; +Cc: linux-iio
On 06/25/2012 10:13 PM, Peter Meerwald wrote:
> Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
All add to fixes-togreg and pull request sent. Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-06-30 12:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-25 21:13 [PATCH 1/3] iio staging: fix potential resource leak in generic_buffer Peter Meerwald
2012-06-25 21:13 ` [PATCH 2/3] iio staging: fix potential memory/resource leaks in find_type_by_name() Peter Meerwald
2012-06-25 21:13 ` [PATCH 3/3] iio staging: fix resource leak in _write_sysfs_int() Peter Meerwald
2012-06-30 12:41 ` [PATCH 1/3] iio staging: fix potential resource leak in generic_buffer Jonathan Cameron
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).