]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: startup: certain goto paths in init_pollers fail to free
authorUman Shahzad <uman@mslm.me>
Thu, 17 Jan 2019 08:21:39 +0000 (08:21 +0000)
committerWilly Tarreau <w@1wt.eu>
Mon, 21 Jan 2019 03:48:48 +0000 (04:48 +0100)
If we fail to initialize pollers due to fdtab/fdinfo/polled_mask
not getting allocated, we free any of those that were allocated
and exit. However the ordering was incorrect, and there was an old
unused and unreachable "fail_cache" path as well, which needs to
be taken when no poller works.

This was introduced with this commit during 1.9-dev :
   cb92f5c ("MINOR: pollers: move polled_mask outside of struct fdtab.")

It needs to be backported to 1.9 only.

src/fd.c

index 84cb9080c27174447d16f88a59d5f2fb046d423c..9434c630031c93dc03d92784ca0760b104885b0f 100644 (file)
--- a/src/fd.c
+++ b/src/fd.c
@@ -528,6 +528,7 @@ int init_pollers()
 
        if ((polled_mask = calloc(global.maxsock, sizeof(unsigned long))) == NULL)
                goto fail_polledmask;
+
        if ((fdinfo = calloc(global.maxsock, sizeof(struct fdinfo))) == NULL)
                goto fail_info;
 
@@ -557,15 +558,13 @@ int init_pollers()
                        return 1;
                }
        } while (!bp || bp->pref == 0);
-       return 0;
 
- fail_cache:
        free(fdinfo);
  fail_info:
-       free(fdtab);
- fail_tab:
        free(polled_mask);
  fail_polledmask:
+       free(fdtab);
+ fail_tab:
        return 0;
 }