[dpdk-dev] event/dpaa: fix integer overflow on max_event_ports at compile time

Message ID 1103cd020ba0357f46650c6de1807cbf35d2a83c.1523595512.git.gowrishankar.m@linux.vnet.ibm.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Gowrishankar April 13, 2018, 5:06 a.m. UTC
  From: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>

dev_info->max_event_ports is uint8_t. dpaa_event_dev_info_get assigns
DPAA_EVENT_MAX_EVENT_PORT (which is RTE_MAX_LCORE, upto 256 in ppc64le)
into this variable, which breaks compile in ppc64le.

Fixes: 9caac5dd1e ("event/dpaa: introduce PMD")

Signed-off-by: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>

--

dpdk/drivers/event/dpaa/dpaa_eventdev.c: In function ‘dpaa_event_dev_info_get’:
dpdk/ppc_64-power8-linuxapp-gcc/include/rte_config.h:23:23: error: large integer implicitly truncated to unsigned type [-Werror=overflow]
 #define RTE_MAX_LCORE 256
                       ^
dpdk/drivers/event/dpaa/dpaa_eventdev.h:29:36: note: in expansion of macro ‘RTE_MAX_LCORE’
 #define DPAA_EVENT_MAX_EVENT_PORT  RTE_MAX_LCORE
                                    ^~~~~~~~~~~~~
dpdk/drivers/event/dpaa/dpaa_eventdev.c:197:3: note: in expansion of macro ‘DPAA_EVENT_MAX_EVENT_PORT’
   DPAA_EVENT_MAX_EVENT_PORT;
   ^~~~~~~~~~~~~~~~~~~~~~~~~

 drivers/event/dpaa/dpaa_eventdev.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Sunil Kumar Kori April 13, 2018, 6:51 a.m. UTC | #1
> -----Original Message-----

> From: Gowrishankar [mailto:gowrishankar.m@linux.vnet.ibm.com]

> Sent: Friday, April 13, 2018 10:37 AM

> To: Sunil Kumar Kori <sunil.kori@nxp.com>; Shreyansh Jain

> <shreyansh.jain@nxp.com>

> Cc: Anatoly Burakov <anatoly.burakov@intel.com>; dev@dpdk.org; Thomas

> Monjalon <thomas@monjalon.net>; Gowrishankar Muthukrishnan

> <gowrishankar.m@linux.vnet.ibm.com>

> Subject: [PATCH] event/dpaa: fix integer overflow on max_event_ports at

> compile time

> 

> From: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>

> 

> dev_info->max_event_ports is uint8_t. dpaa_event_dev_info_get assigns

> DPAA_EVENT_MAX_EVENT_PORT (which is RTE_MAX_LCORE, upto 256 in

> ppc64le) into this variable, which breaks compile in ppc64le.

> 

> Fixes: 9caac5dd1e ("event/dpaa: introduce PMD")

> 

> Signed-off-by: Gowrishankar Muthukrishnan

> <gowrishankar.m@linux.vnet.ibm.com>

> 


Acked-by: Sunil Kumar Kori <sunil.kori@nxp.com>
  
Thomas Monjalon April 16, 2018, 2:45 p.m. UTC | #2
> > From: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
> > 
> > dev_info->max_event_ports is uint8_t. dpaa_event_dev_info_get assigns
> > DPAA_EVENT_MAX_EVENT_PORT (which is RTE_MAX_LCORE, upto 256 in
> > ppc64le) into this variable, which breaks compile in ppc64le.
> > 
> > Fixes: 9caac5dd1e ("event/dpaa: introduce PMD")

Cc: stable@dpdk.org
 
> > Signed-off-by: Gowrishankar Muthukrishnan
> > <gowrishankar.m@linux.vnet.ibm.com>
> > 
> 
> Acked-by: Sunil Kumar Kori <sunil.kori@nxp.com>

Applied, thanks
  

Patch

diff --git a/drivers/event/dpaa/dpaa_eventdev.h b/drivers/event/dpaa/dpaa_eventdev.h
index 918fe35..583e46c 100644
--- a/drivers/event/dpaa/dpaa_eventdev.h
+++ b/drivers/event/dpaa/dpaa_eventdev.h
@@ -26,7 +26,7 @@ 
 #define DPAA_EVENT_MAX_QUEUE_FLOWS		2048
 #define DPAA_EVENT_MAX_QUEUE_PRIORITY_LEVELS	8
 #define DPAA_EVENT_MAX_EVENT_PRIORITY_LEVELS	0
-#define DPAA_EVENT_MAX_EVENT_PORT		RTE_MAX_LCORE
+#define DPAA_EVENT_MAX_EVENT_PORT		RTE_MIN(RTE_MAX_LCORE, INT8_MAX)
 #define DPAA_EVENT_MAX_PORT_DEQUEUE_DEPTH	8
 #define DPAA_EVENT_PORT_DEQUEUE_TIMEOUT_NS	100UL
 #define DPAA_EVENT_PORT_DEQUEUE_TIMEOUT_INVALID	((uint64_t)-1)