blobfs: removed unaligned memory access
Replaced (uint64_t *) dereference of (char *) variable with memcpy to avoid unaligned memory access. It fixes the following error reported by ubsan: spdk/lib/blobfs/blobfs.c:1492:2: runtime error: load of misaligned address 0x00000047a136 for type 'uint64_t', which requires 8 byte alignment Change-Id: I5f3f28a52b8cbe3eb30394ae7ebd0e64b683db57 Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/454886 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
2fac8bc76b
commit
275f0c341c
@ -1473,13 +1473,21 @@ spdk_fs_delete_file_async(struct spdk_filesystem *fs, const char *name,
|
||||
spdk_bs_delete_blob(fs->bs, blobid, blob_delete_cb, req);
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
fs_name_to_uint64(const char *name)
|
||||
{
|
||||
uint64_t result = 0;
|
||||
memcpy(&result, name, spdk_min(sizeof(result), strlen(name)));
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
__fs_delete_file_done(void *arg, int fserrno)
|
||||
{
|
||||
struct spdk_fs_request *req = arg;
|
||||
struct spdk_fs_cb_args *args = &req->args;
|
||||
|
||||
spdk_trace_record(TRACE_BLOBFS_DELETE_DONE, 0, 0, 0, *((uint64_t *)args->op.delete.name));
|
||||
spdk_trace_record(TRACE_BLOBFS_DELETE_DONE, 0, 0, 0, fs_name_to_uint64(args->op.delete.name));
|
||||
__wake_caller(args, fserrno);
|
||||
}
|
||||
|
||||
@ -1489,7 +1497,7 @@ __fs_delete_file(void *arg)
|
||||
struct spdk_fs_request *req = arg;
|
||||
struct spdk_fs_cb_args *args = &req->args;
|
||||
|
||||
spdk_trace_record(TRACE_BLOBFS_DELETE_START, 0, 0, 0, *((uint64_t *)args->op.delete.name));
|
||||
spdk_trace_record(TRACE_BLOBFS_DELETE_START, 0, 0, 0, fs_name_to_uint64(args->op.delete.name));
|
||||
spdk_fs_delete_file_async(args->fs, args->op.delete.name, __fs_delete_file_done, req);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user