summaryrefslogtreecommitdiffstats
path: root/xlators/performance/readdir-ahead
diff options
context:
space:
mode:
authorXavi Hernandez <xhernandez@redhat.com>2019-12-20 14:14:32 +0100
committerAmar Tumballi <amarts@gmail.com>2020-01-10 00:58:19 +0000
commit00c090b093c147a95bfb8fce93f08303993e1995 (patch)
tree537f9d4104bc1290dc2419c4ce9341bc6ee31dc8 /xlators/performance/readdir-ahead
parent1166df1920dd9b2bd5fce53ab49d27117db40238 (diff)
multiple: fix bad type cast
When using inode_ctx_get() or inode_ctx_set(), a 'uint64_t *' is expected. In many cases, the value to retrieve or store is a pointer, which will be of smaller size in some architectures (for example 32-bits). In this case, directly passing the address of the pointer casted to an 'uint64_t *' is wrong and can cause memory corruption. Change-Id: Iae616da9dda528df6743fa2f65ae5cff5ad23258 Signed-off-by: Xavi Hernandez <xhernandez@redhat.com> Fixes: bz#1785611
Diffstat (limited to 'xlators/performance/readdir-ahead')
-rw-r--r--xlators/performance/readdir-ahead/src/readdir-ahead.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/xlators/performance/readdir-ahead/src/readdir-ahead.c b/xlators/performance/readdir-ahead/src/readdir-ahead.c
index 933941d8a92..4ba7ee7077a 100644
--- a/xlators/performance/readdir-ahead/src/readdir-ahead.c
+++ b/xlators/performance/readdir-ahead/src/readdir-ahead.c
@@ -98,7 +98,8 @@ __rda_inode_ctx_get(inode_t *inode, xlator_t *this)
GF_ATOMIC_INIT(ctx_p->generation, 0);
- ret = __inode_ctx_set1(inode, this, (uint64_t *)&ctx_p);
+ ctx_uint = (uint64_t)(uintptr_t)ctx_p;
+ ret = __inode_ctx_set1(inode, this, &ctx_uint);
if (ret < 0) {
GF_FREE(ctx_p);
return NULL;