* [PATCH] resolv_conf: release lock on allocation failure (bug 30527)
@ 2023-06-07 9:30 Andreas Schwab
2023-06-07 9:57 ` Florian Weimer
0 siblings, 1 reply; 2+ messages in thread
From: Andreas Schwab @ 2023-06-07 9:30 UTC (permalink / raw)
To: libc-alpha
When the initial allocation of global fails, the local lock is left
locked.
---
resolv/resolv_conf.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/resolv/resolv_conf.c b/resolv/resolv_conf.c
index bd5890773b..8bc9edc634 100644
--- a/resolv/resolv_conf.c
+++ b/resolv/resolv_conf.c
@@ -93,7 +93,10 @@ get_locked_global (void)
{
global_copy = calloc (1, sizeof (*global));
if (global_copy == NULL)
- return NULL;
+ {
+ __libc_lock_unlock (lock);
+ return NULL;
+ }
atomic_store_relaxed (&global, global_copy);
resolv_conf_array_init (&global_copy->array);
}
--
2.41.0
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] resolv_conf: release lock on allocation failure (bug 30527)
2023-06-07 9:30 [PATCH] resolv_conf: release lock on allocation failure (bug 30527) Andreas Schwab
@ 2023-06-07 9:57 ` Florian Weimer
0 siblings, 0 replies; 2+ messages in thread
From: Florian Weimer @ 2023-06-07 9:57 UTC (permalink / raw)
To: Andreas Schwab via Libc-alpha; +Cc: Andreas Schwab
* Andreas Schwab via Libc-alpha:
> When the initial allocation of global fails, the local lock is left
> locked.
> ---
> resolv/resolv_conf.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/resolv/resolv_conf.c b/resolv/resolv_conf.c
> index bd5890773b..8bc9edc634 100644
> --- a/resolv/resolv_conf.c
> +++ b/resolv/resolv_conf.c
> @@ -93,7 +93,10 @@ get_locked_global (void)
> {
> global_copy = calloc (1, sizeof (*global));
> if (global_copy == NULL)
> - return NULL;
> + {
> + __libc_lock_unlock (lock);
> + return NULL;
> + }
> atomic_store_relaxed (&global, global_copy);
> resolv_conf_array_init (&global_copy->array);
> }
> --
Okay.
Thanks,
Florian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-07 9:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-07 9:30 [PATCH] resolv_conf: release lock on allocation failure (bug 30527) Andreas Schwab
2023-06-07 9:57 ` Florian Weimer
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 read-only IMAP folder(s) and NNTP newsgroup(s).