From: Huisong Li Date: Fri, 23 Apr 2021 11:01:11 +0000 (+0800) Subject: sched: fix profile allocation failure handling X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=a042481ecd9e890b7fc088f9d2a3a6b6e82d3a4c;p=dpdk.git sched: fix profile allocation failure handling This patch fixes return value judgment when allocate memory to store the subport profile, and releases memory of 'rte_sched_port' if code fails to apply for this memory. Fixes: 0ea4c6afcaf1 ("sched: add subport profile table") Cc: stable@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Min Hu (Connor) Acked-by: Cristian Dumitrescu --- diff --git a/lib/sched/rte_sched.c b/lib/sched/rte_sched.c index cd87e688e4..df0ab5cab9 100644 --- a/lib/sched/rte_sched.c +++ b/lib/sched/rte_sched.c @@ -961,9 +961,9 @@ rte_sched_port_config(struct rte_sched_port_params *params) /* Allocate memory to store the subport profile */ port->subport_profiles = rte_zmalloc_socket("subport_profile", size2, RTE_CACHE_LINE_SIZE, params->socket); - if (port == NULL) { + if (port->subport_profiles == NULL) { RTE_LOG(ERR, SCHED, "%s: Memory allocation fails\n", __func__); - + rte_free(port); return NULL; }