]> www.infradead.org Git - users/mchehab/rasdaemon.git/commitdiff
fix file descriptor leak in ras-report.c:setup_report_socket()
authorSergio Gelato <Sergio.Gelato@astro.su.se>
Wed, 19 Sep 2018 14:59:35 +0000 (11:59 -0300)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Wed, 4 Sep 2019 23:50:33 +0000 (20:50 -0300)
A running instance of rasdaemon was seen to hit the limit on open file
descriptors. Most of the the descriptors were AF_UNIX STREAM sockets.
At the same time the limit was hit, attempts by rasdaemon to open the
SQLite database started failing with SQLite error 14.

This patch avoids leaking a socket file descriptor each time the connect()
call fails.

Signed-off-by: Sergio Gelato <Sergio.Gelato@astro.su.se>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
ras-report.c

index 661da84e6b077a90e88f6a1aaa291e9a98455794..2710eacdf374fc3058056755ecec9a310b083778 100644 (file)
@@ -37,7 +37,8 @@ static int setup_report_socket(void){
        addr.sun_path[sizeof(addr.sun_path) - 1] = '\0';
 
        rc = connect(sockfd, (struct sockaddr *)&addr, sizeof(struct sockaddr_un));
-       if (rc < 0){
+       if (rc < 0) {
+               close(sockfd);
                return -1;
        }