Skip to content

Commit

Permalink
sched: fix profile allocation failure handling
Browse files Browse the repository at this point in the history
[ upstream commit a042481 ]

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: 0ea4c6a ("sched: add subport profile table")

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
  • Loading branch information
LiHuiSong1 authored and bluca committed Jul 26, 2021
1 parent 0cd4f7e commit 41a170f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/librte_sched/rte_sched.c
Expand Up @@ -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;
}

Expand Down

0 comments on commit 41a170f

Please sign in to comment.