diff --git a/tempesta_fw/cache.c b/tempesta_fw/cache.c index 8e45da98b..487d647a7 100644 --- a/tempesta_fw/cache.c +++ b/tempesta_fw/cache.c @@ -1620,13 +1620,14 @@ cache_req_process_node(TfwHttpReq *req, tfw_http_cache_cb_t action) if (!tfw_handle_validation_req(req, ce)) goto put; - resp = tfw_cache_build_resp(req, ce); + if (!(resp = tfw_cache_build_resp(req, ce))) + goto out; /* * RFC 7234 p.4 Constructing Responses from Caches: * When a stored response is used to satisfy a request without * validation, a cache MUST generate an Age header field. */ - if (resp && tfw_cache_set_hdr_age((TfwHttpMsg *)resp, ce)) { + if (tfw_cache_set_hdr_age((TfwHttpMsg *)resp, ce)) { TFW_WARN("Unable to add Age: header, cached" " response [%p] dropped\n", resp); TFW_INC_STAT_BH(clnt.msgs_otherr); diff --git a/tempesta_fw/sched/tfw_sched_ratio.c b/tempesta_fw/sched/tfw_sched_ratio.c index f4477a4fa..1ff68b6a6 100644 --- a/tempesta_fw/sched/tfw_sched_ratio.c +++ b/tempesta_fw/sched/tfw_sched_ratio.c @@ -1044,17 +1044,20 @@ tfw_sched_ratio_srvdesc_setup_srv(TfwServer *srv, TfwRatioSrvDesc *srvdesc) conn = srvdesc->conn; list_for_each_entry(srv_conn, &srv->conn_list, list) { if (unlikely(ci++ == srv->conn_n)) - return -EINVAL; + goto err; *conn++ = srv_conn; } if (unlikely(ci != srv->conn_n)) - return -EINVAL; + goto err; srvdesc->conn_n = srv->conn_n; srvdesc->srv = srv; atomic64_set(&srvdesc->counter, 0); return 0; +err: + kfree(srvdesc->conn); + return -EINVAL; } /** @@ -1258,8 +1261,10 @@ tfw_sched_ratio_add_srv(TfwServer *srv) if (!(srvdesc = kzalloc(sizeof(TfwRatioSrvDesc), GFP_KERNEL))) return -ENOMEM; - if ((r = tfw_sched_ratio_srvdesc_setup_srv(srv, srvdesc))) + if ((r = tfw_sched_ratio_srvdesc_setup_srv(srv, srvdesc))) { + kfree(srvdesc); return r; + } rcu_assign_pointer(srv->sched_data, srvdesc); @@ -1270,6 +1275,7 @@ static void tfw_sched_ratio_put_srv_data(struct rcu_head *rcu) { TfwRatioSrvDesc *srvdesc = container_of(rcu, TfwRatioSrvDesc, rcu); + kfree(srvdesc->conn); kfree(srvdesc); } diff --git a/tempesta_fw/t/unit/test_http_parser.c b/tempesta_fw/t/unit/test_http_parser.c index 5bea9623d..ec8fba2d7 100644 --- a/tempesta_fw/t/unit/test_http_parser.c +++ b/tempesta_fw/t/unit/test_http_parser.c @@ -68,7 +68,7 @@ split_and_parse_n(unsigned char *str, int type, size_t len, size_t chunks) static int set_sample_req(unsigned char *str) { - size_t len = len = strlen(str); + size_t len = strlen(str); int r; if (sample_req)