Skip to contentSkip to conversation

rte_sched: check newly allocated pointer

PATCH Superseded Thierry Herbelot 3 participants 5 messages May 24, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rte_sched: check newly allocated pointer

Check port->subport_profiles after it was allocated.

Fixes 0ea4c6afcaf14 ("sched: add subport profile table")
Cc Cristian Dumitrescu <[email protected]>
Cc Jasvinder Singh <[email protected]>
---
 lib/sched/rte_sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/sched/rte_sched.c +1 -1
index cd87e688e489..4a2c0e27550d 100644
@@ -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;
Signature · 1 line
2.29.2
Acked-by on v1 1/1
#1 lore raw
Quoted 40 lines

-----Original Message-----
From: Thierry Herbelot <[email protected]>
Sent: Monday, May 24, 2021 9:58 AM
To: [email protected]
Cc: Thierry Herbelot <[email protected]>; Thomas Monjalon <[email protected]>; [email protected]; Dumitrescu, Cristian <[email protected]>; Singh, Jasvinder <[email protected]>
Subject: [PATCH] rte_sched: check newly allocated pointer

Check port->subport_profiles after it was allocated.

Fixes 0ea4c6afcaf14 ("sched: add subport profile table")
Cc Cristian Dumitrescu <[email protected]>
Cc Jasvinder Singh <[email protected]>
---
 lib/sched/rte_sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/sched/rte_sched.c +1 -1
index cd87e688e489..4a2c0e27550d 100644
@@ -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__);

Quoted 3 lines

return NULL;
--
2.29.2

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

#2 lore raw

PATCH v2 1/1 sched: check newly allocated pointer

In reply to Thierry Herbelot

Check port->subport_profiles after it was allocated.

Fixes 0ea4c6afcaf14 ("sched: add subport profile table")
Cc Cristian Dumitrescu <[email protected]>
Cc Jasvinder Singh <[email protected]>

--
V2: reword patch title

---
 lib/sched/rte_sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/sched/rte_sched.c +1 -1
index cd87e688e489..4a2c0e27550d 100644
@@ -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;
Signature · 1 line
2.29.2
Acked-by on v2 1/1
#3 lore raw

Re: [dpdk-dev] [PATCH v2] sched: check newly allocated pointer

Quoted 42 lines

-----Original Message-----
From: Thierry Herbelot <[email protected]>
Sent: Monday, May 24, 2021 12:30 PM
To: [email protected]
Cc: Thierry Herbelot <[email protected]>; Thomas Monjalon <[email protected]>; [email protected]; Dumitrescu, Cristian <[email protected]>; Singh, Jasvinder <[email protected]>
Subject: [PATCH v2] sched: check newly allocated pointer

Check port->subport_profiles after it was allocated.

Fixes 0ea4c6afcaf14 ("sched: add subport profile table")
Cc Cristian Dumitrescu <[email protected]>
Cc Jasvinder Singh <[email protected]>

--
V2: reword patch title

---
 lib/sched/rte_sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/sched/rte_sched.c +1 -1
index cd87e688e489..4a2c0e27550d 100644
@@ -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__);

Quoted 3 lines

return NULL;
--
2.29.2

#4 lore raw

Re: [dpdk-dev] [PATCH v2] sched: check newly allocated pointer

In reply to Thierry Herbelot

Hi, Thierry,
This bug has been fixed in my earlier patch, please refer to:
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

Thanks.

Quoted 28 lines · Thierry Herbelot

Check port->subport_profiles after it was allocated.

Fixes 0ea4c6afcaf14 ("sched: add subport profile table")
Cc Cristian Dumitrescu <[email protected]>
Cc Jasvinder Singh <[email protected]>

--
V2: reword patch title

---
  lib/sched/rte_sched.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
lib/sched/rte_sched.c +1 -1
index cd87e688e489..4a2c0e27550d 100644
@@ -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;