summaryrefslogtreecommitdiffstats
path: root/xlators/performance/io-cache/src/io-cache.c
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/io-cache/src/io-cache.c
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/io-cache/src/io-cache.c')
-rw-r--r--xlators/performance/io-cache/src/io-cache.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c
index 821ed65bd05..c007e0a355d 100644
--- a/xlators/performance/io-cache/src/io-cache.c
+++ b/xlators/performance/io-cache/src/io-cache.c
@@ -381,14 +381,12 @@ ioc_forget(xlator_t *this, inode_t *inode)
static int32_t
ioc_invalidate(xlator_t *this, inode_t *inode)
{
- uint64_t ioc_addr = 0;
- ioc_inode_t *ioc_inode = NULL;
+ uint64_t ioc_inode = 0;
- inode_ctx_get(inode, this, (uint64_t *)&ioc_addr);
- ioc_inode = (void *)(uintptr_t)ioc_addr;
+ inode_ctx_get(inode, this, &ioc_inode);
if (ioc_inode)
- ioc_inode_flush(ioc_inode);
+ ioc_inode_flush((ioc_inode_t *)(uintptr_t)ioc_inode);
return 0;
}