DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] ethdev: fix wrong sizeof argument in malloc function
@ 2017-05-09  5:22 Kuba Kozak
  2017-05-09  8:46 ` Van Haaren, Harry
  0 siblings, 1 reply; 3+ messages in thread
From: Kuba Kozak @ 2017-05-09  5:22 UTC (permalink / raw)
  To: dev; +Cc: harry.van.haaren, deepak.k.jain, michalx.k.jastrzebski, kubax.kozak

From: Michal Jastrzebski <michalx.k.jastrzebski@intel.com>

Coverity reported that an argument for sizeof was used improperly. 
We should allocate memory for value size that pointer points to,
instead of pointer size itself. 

Coverity issue: 144522
Fixes: 79c913a42f0e ("ethdev: retrieve xstats by ID")

Signed-off-by: Michal Jastrzebski <michalx.k.jastrzebski@intel.com>
---
 lib/librte_ether/rte_ethdev.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 8cf8b65..83898a8 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1714,7 +1714,7 @@ struct rte_eth_dev *
 
 		size = rte_eth_xstats_get_by_id(port_id, NULL, NULL, 0);
 
-		values_copy = malloc(sizeof(values_copy) * size);
+		values_copy = malloc(sizeof(*values_copy) * size);
 		if (!values_copy) {
 			RTE_PMD_DEBUG_TRACE(
 			    "ERROR: can't allocate memory for values_copy\n");
-- 
1.7.9.5

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

* Re: [dpdk-dev] [PATCH] ethdev: fix wrong sizeof argument in malloc function
  2017-05-09  5:22 [dpdk-dev] [PATCH] ethdev: fix wrong sizeof argument in malloc function Kuba Kozak
@ 2017-05-09  8:46 ` Van Haaren, Harry
  2017-05-10 14:52   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Van Haaren, Harry @ 2017-05-09  8:46 UTC (permalink / raw)
  To: dev, Thomas Monjalon; +Cc: Jain, Deepak K, Jastrzebski, MichalX K, Kozak, KubaX

> From: Kozak, KubaX
> Sent: Tuesday, May 9, 2017 6:22 AM
> To: dev@dpdk.org
> Cc: Van Haaren, Harry <harry.van.haaren@intel.com>; Jain, Deepak K <deepak.k.jain@intel.com>;
> Jastrzebski, MichalX K <michalx.k.jastrzebski@intel.com>; Kozak, KubaX <kubax.kozak@intel.com>
> Subject: [PATCH] ethdev: fix wrong sizeof argument in malloc function
> 
> From: Michal Jastrzebski <michalx.k.jastrzebski@intel.com>
> 
> Coverity reported that an argument for sizeof was used improperly.
> We should allocate memory for value size that pointer points to,
> instead of pointer size itself.
> 
> Coverity issue: 144522
> Fixes: 79c913a42f0e ("ethdev: retrieve xstats by ID")
> 
> Signed-off-by: Michal Jastrzebski <michalx.k.jastrzebski@intel.com>

Please consider merging these in 17.05, this is an important fix for 32 bit systems.

Acked-by: Harry van Haaren <harry.van.haaren@intel.com>


This patch fixes a bug of the same as detailed here:
http://dpdk.org/ml/archives/dev/2017-May/065487.html

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

* Re: [dpdk-dev] [PATCH] ethdev: fix wrong sizeof argument in malloc function
  2017-05-09  8:46 ` Van Haaren, Harry
@ 2017-05-10 14:52   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2017-05-10 14:52 UTC (permalink / raw)
  To: Kozak, KubaX
  Cc: dev, Van Haaren, Harry, Jain, Deepak K, Jastrzebski, MichalX K

09/05/2017 10:46, Van Haaren, Harry:
> > From: Kozak, KubaX
> > Sent: Tuesday, May 9, 2017 6:22 AM
> > To: dev@dpdk.org
> > Cc: Van Haaren, Harry <harry.van.haaren@intel.com>; Jain, Deepak K <deepak.k.jain@intel.com>;
> > Jastrzebski, MichalX K <michalx.k.jastrzebski@intel.com>; Kozak, KubaX <kubax.kozak@intel.com>
> > Subject: [PATCH] ethdev: fix wrong sizeof argument in malloc function
> > 
> > From: Michal Jastrzebski <michalx.k.jastrzebski@intel.com>
> > 
> > Coverity reported that an argument for sizeof was used improperly.
> > We should allocate memory for value size that pointer points to,
> > instead of pointer size itself.
> > 
> > Coverity issue: 144522
> > Fixes: 79c913a42f0e ("ethdev: retrieve xstats by ID")
> > 
> > Signed-off-by: Michal Jastrzebski <michalx.k.jastrzebski@intel.com>
> 
> Please consider merging these in 17.05, this is an important fix for 32 bit systems.
> 
> Acked-by: Harry van Haaren <harry.van.haaren@intel.com>
> 
> 
> This patch fixes a bug of the same as detailed here:
> http://dpdk.org/ml/archives/dev/2017-May/065487.html

Applied with title:
	ethdev: fix xstats by ID on 32-bit
Thanks

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

end of thread, other threads:[~2017-05-10 14:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-09  5:22 [dpdk-dev] [PATCH] ethdev: fix wrong sizeof argument in malloc function Kuba Kozak
2017-05-09  8:46 ` Van Haaren, Harry
2017-05-10 14:52   ` Thomas Monjalon

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).