diff options
author | Thanos Makatos <thanos.makatos@nutanix.com> | 2019-12-17 05:16:00 -0500 |
---|---|---|
committer | Thanos <tmakatos@gmail.com> | 2019-12-17 11:35:07 +0000 |
commit | e884f7c22dea862812dba60b94f676394e8e3ce4 (patch) | |
tree | 53745d257cd6fb5a9c20c045cc43dae968bc34fc /lib | |
parent | 2d774b83fac02d7cec699a9464c72d17dbbbe6ed (diff) | |
download | libvfio-user-e884f7c22dea862812dba60b94f676394e8e3ce4.zip libvfio-user-e884f7c22dea862812dba60b94f676394e8e3ce4.tar.gz libvfio-user-e884f7c22dea862812dba60b94f676394e8e3ce4.tar.bz2 |
return correct error code on device map failure from user space
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libmuser.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/libmuser.c b/lib/libmuser.c index e83b477..aeb245c 100644 --- a/lib/libmuser.c +++ b/lib/libmuser.c @@ -603,19 +603,19 @@ muser_mmap(lm_ctx_t *lm_ctx, struct muser_cmd *cmd) region = lm_get_region(offset, len, &offset); if (region < 0) { lm_log(lm_ctx, LM_ERR, "bad region %d\n", region); - err = region; + err = EINVAL; goto out; } if (lm_ctx->pci_info.reg_info[region].map == NULL) { lm_log(lm_ctx, LM_ERR, "region not mmapable\n"); - err = -ENOTSUP; + err = ENOTSUP; goto out; } addr = lm_ctx->pci_info.reg_info[region].map(lm_ctx->pvt, offset, len); if ((void *)addr == MAP_FAILED) { - err = -errno; + err = errno; lm_log(lm_ctx, LM_ERR, "failed to mmap: %m\n"); goto out; } @@ -624,10 +624,10 @@ muser_mmap(lm_ctx_t *lm_ctx, struct muser_cmd *cmd) out: if (err != 0) { lm_log(lm_ctx, LM_ERR, "failed to mmap device memory %#x@%#lx: %s\n", - len, offset, strerror(-errno)); + len, offset, strerror(err)); } - return err; + return -err; } /* |