BUG #17186: In connect.c, the lock connections_mutex is not correctly released(Line 463) at the return(Line 522) - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #17186: In connect.c, the lock connections_mutex is not correctly released(Line 463) at the return(Line 522)
Date
Msg-id 17186-b4cfd8f0eb4d1dee@postgresql.org
Whole thread Raw
Responses Re: BUG #17186: In connect.c, the lock connections_mutex is not correctly released(Line 463) at the return(Line 522)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      17186
Logged by:          An improper locking bug due to the unreleased lock connections_mutex in
/ecpg/ecpglib/connect.c
Email address:      ryancaicse@gmail.com
PostgreSQL version: 14beta3
Operating system:   All
Description:

This is a possible improper locking bug, which can lead to resource leaks
and even deadlock. I am not sure whether it can lead to a security
problem.
The problem is that the lock connections_mutex should be released at the end
of the function. But it not released when conn_keywords == NULL ||
conn_values == NULL (ecpg_alloc got errors and return NULL).
Thank you for your checking.

Locations:

https://github.com/postgres/postgres/blob/c30f54ad732ca5c8762bb68bbe0f51de9137dd72/src/interfaces/ecpg/ecpglib/connect.c#L463

https://github.com/postgres/postgres/blob/c30f54ad732ca5c8762bb68bbe0f51de9137dd72/src/interfaces/ecpg/ecpglib/connect.c#L522


pgsql-bugs by date:

Previous
From: Michael Paquier
Date:
Subject: Re: BUG #17184: When using openssl, the memory of a static variable is not freed in libpq
Next
From: Michael Paquier
Date:
Subject: Re: BUG #17186: In connect.c, the lock connections_mutex is not correctly released(Line 463) at the return(Line 522)