memalloc: fix pointer dereferencing

Message ID 7b4ee39eb515cfebabefd43c77294ee55ab8092d.1546964889.git.anatoly.burakov@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series memalloc: fix pointer dereferencing |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/mellanox-Performance-Testing fail Performance Testing issues
ci/intel-Performance-Testing success Performance Testing PASS
ci/Intel-compilation success Compilation OK

Commit Message

Burakov, Anatoly Jan. 8, 2019, 4:46 p.m. UTC
  The original code was supposed to overwrite the value pointed to
by the pointer, but the new one is instead overwriting the
pointer value itself, which has no effect outside that function.
Fix it by adding a pointer dereference.

Fixes: 582bed1e1d1d ("mem: support mapping hugepages at runtime")
Cc: stable@dpdk.org

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/linuxapp/eal/eal_memalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Thomas Monjalon Jan. 14, 2019, 2:52 p.m. UTC | #1
08/01/2019 17:46, Anatoly Burakov:
> The original code was supposed to overwrite the value pointed to
> by the pointer, but the new one is instead overwriting the
> pointer value itself, which has no effect outside that function.
> Fix it by adding a pointer dereference.
> 
> Fixes: 582bed1e1d1d ("mem: support mapping hugepages at runtime")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>

Applied with below title, thanks:
	mem: fix storing old policy
  

Patch

diff --git a/lib/librte_eal/linuxapp/eal/eal_memalloc.c b/lib/librte_eal/linuxapp/eal/eal_memalloc.c
index 60a0a680f..ccf268679 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memalloc.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memalloc.c
@@ -176,7 +176,7 @@  prepare_numa(int *oldpolicy, struct bitmask *oldmask, int socket_id)
 		RTE_LOG(ERR, EAL,
 			"Failed to get current mempolicy: %s. "
 			"Assuming MPOL_DEFAULT.\n", strerror(errno));
-		oldpolicy = MPOL_DEFAULT;
+		*oldpolicy = MPOL_DEFAULT;
 	}
 	RTE_LOG(DEBUG, EAL,
 		"Setting policy MPOL_PREFERRED for socket %d\n",