DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] mem: fix overflowed return value
@ 2016-04-22 10:44 Michal Kobylinski
  2016-04-22 16:24 ` Stephen Hemminger
  0 siblings, 1 reply; 4+ messages in thread
From: Michal Kobylinski @ 2016-04-22 10:44 UTC (permalink / raw)
  To: thomas.monjalon, dev; +Cc: Michal Kobylinski

Fix issue reported by Coverity.

Coverity ID 13255: Overflowed return value: The return value will be too
small or even negative, likely resulting in unexpected behavior in a
caller that uses the return value. In rte_mem_virt2phy: An integer
overflow occurs, with the overflowed value used as the return value of
the function

Fixes: 3097de6e6bfb ("mem: get physical address of any pointer")

Signed-off-by: Michal Kobylinski <michalx.kobylinski@intel.com>
---
 lib/librte_eal/linuxapp/eal/eal_memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
index 5b9132c..6ceca5b 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memory.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -195,7 +195,7 @@ rte_mem_virt2phy(const void *virtaddr)
 	 * the pfn (page frame number) are bits 0-54 (see
 	 * pagemap.txt in linux Documentation)
 	 */
-	physaddr = ((page & 0x7fffffffffffffULL) * page_size)
+	physaddr = (uint64_t)((page & 0x7fffffffffffffULL) * page_size)
 		+ ((unsigned long)virtaddr % page_size);
 	close(fd);
 	return physaddr;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-06-28  8:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-22 10:44 [dpdk-dev] [PATCH] mem: fix overflowed return value Michal Kobylinski
2016-04-22 16:24 ` Stephen Hemminger
2016-06-08 11:40   ` Mrzyglod, DanielX T
2016-06-28  8:06     ` Jastrzebski, MichalX K

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).