rte_sched: check newly allocated pointer

Message ID 20210524085737.15717-1-thierry.herbelot@6wind.com (mailing list archive)
State Superseded, archived
Headers
Series rte_sched: check newly allocated pointer |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot success github build: passed
ci/iol-abi-testing success Testing PASS
ci/iol-testing fail Testing issues
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-mellanox-Functional fail Functional Testing issues

Commit Message

Thierry Herbelot May 24, 2021, 8:57 a.m. UTC
  Check port->subport_profiles after it was allocated.

Fixes: 0ea4c6afcaf14 ("sched: add subport profile table")
Cc: stable@dpdk.org
Cc: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Cc: Jasvinder Singh <jasvinder.singh@intel.com>

Signed-off-by: Thierry Herbelot <thierry.herbelot@6wind.com>
---
 lib/sched/rte_sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Cristian Dumitrescu May 24, 2021, 11:28 a.m. UTC | #1
> -----Original Message-----
> From: Thierry Herbelot <thierry.herbelot@6wind.com>
> Sent: Monday, May 24, 2021 9:58 AM
> To: dev@dpdk.org
> Cc: Thierry Herbelot <thierry.herbelot@6wind.com>; Thomas Monjalon
> <thomas@monjalon.net>; stable@dpdk.org; Dumitrescu, Cristian
> <cristian.dumitrescu@intel.com>; Singh, Jasvinder
> <jasvinder.singh@intel.com>
> Subject: [PATCH] rte_sched: check newly allocated pointer
> 
> Check port->subport_profiles after it was allocated.
> 
> Fixes: 0ea4c6afcaf14 ("sched: add subport profile table")
> Cc: stable@dpdk.org
> Cc: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> Cc: Jasvinder Singh <jasvinder.singh@intel.com>
> 
> Signed-off-by: Thierry Herbelot <thierry.herbelot@6wind.com>
> ---
>  lib/sched/rte_sched.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/sched/rte_sched.c b/lib/sched/rte_sched.c
> index cd87e688e489..4a2c0e27550d 100644
> --- a/lib/sched/rte_sched.c
> +++ b/lib/sched/rte_sched.c
> @@ -961,7 +961,7 @@ 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__);
> 
>  		return NULL;
> --
> 2.29.2

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Thanks very much, Thierry!

It would be great though if you could send V2 with "sched" instead of "rte_sched" in the title:
	[PATCH V2] sched: check newly allocated pointer
  

Patch

diff --git a/lib/sched/rte_sched.c b/lib/sched/rte_sched.c
index cd87e688e489..4a2c0e27550d 100644
--- a/lib/sched/rte_sched.c
+++ b/lib/sched/rte_sched.c
@@ -961,7 +961,7 @@  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__);
 
 		return NULL;