* [PATCH master] libfile: don't leak file descriptors in compare_file
@ 2023-04-14 15:20 Ahmad Fatoum
2023-04-17 6:57 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2023-04-14 15:20 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
Depending on the state of environment, running
while saveenv; do true; done
Can quickly lead to:
saving environment
could not open /dev/mmc2.barebox-environment: error 24
saveenv: error 24
Because the leaked file descriptors gobble up the 128 we have
preallocated. Fix this.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
lib/libfile.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/libfile.c b/lib/libfile.c
index b967232d198e..ebd1de3d8e4d 100644
--- a/lib/libfile.c
+++ b/lib/libfile.c
@@ -542,8 +542,10 @@ int compare_file(const char *f1, const char *f2)
if (ret)
goto err_out2;
- if (s1.st_size != s2.st_size)
- return 1;
+ if (s1.st_size != s2.st_size) {
+ ret = 1;
+ goto err_out2;
+ }
buf1 = xmalloc(RW_BUF_SIZE);
buf2 = xmalloc(RW_BUF_SIZE);
--
2.39.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH master] libfile: don't leak file descriptors in compare_file
2023-04-14 15:20 [PATCH master] libfile: don't leak file descriptors in compare_file Ahmad Fatoum
@ 2023-04-17 6:57 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2023-04-17 6:57 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox
On Fri, Apr 14, 2023 at 05:20:32PM +0200, Ahmad Fatoum wrote:
> Depending on the state of environment, running
>
> while saveenv; do true; done
>
> Can quickly lead to:
>
> saving environment
> could not open /dev/mmc2.barebox-environment: error 24
> saveenv: error 24
>
> Because the leaked file descriptors gobble up the 128 we have
> preallocated. Fix this.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> lib/libfile.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/lib/libfile.c b/lib/libfile.c
> index b967232d198e..ebd1de3d8e4d 100644
> --- a/lib/libfile.c
> +++ b/lib/libfile.c
> @@ -542,8 +542,10 @@ int compare_file(const char *f1, const char *f2)
> if (ret)
> goto err_out2;
>
> - if (s1.st_size != s2.st_size)
> - return 1;
> + if (s1.st_size != s2.st_size) {
> + ret = 1;
> + goto err_out2;
> + }
>
> buf1 = xmalloc(RW_BUF_SIZE);
> buf2 = xmalloc(RW_BUF_SIZE);
> --
> 2.39.2
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-04-17 6:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-14 15:20 [PATCH master] libfile: don't leak file descriptors in compare_file Ahmad Fatoum
2023-04-17 6:57 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox