vma = find_vma(current->mm, address);
if (!vma || !vma->vm_file) {
pr_err("cannot find vma\n");
+ rc = -EBADF;
goto err;
}
fd = iterate_fd(current->files, 0, match_file, vma->vm_file);
if (fd == 0) {
pr_err("iterate_fd failed\n");
+ rc = -EBADF;
goto err;
}
page_offset = offset/PAGE_SIZE;
dmabuf = dma_buf_get(fd - 1);
+ if (IS_ERR_OR_NULL(dmabuf)) {
+ pr_err("dma_buf_get failed fd %d ret %pK\n", fd, dmabuf);
+ rc = -EBADF;
+ goto err;
+ }
attach = dma_buf_attach(dmabuf, hab_driver.dev);
if (IS_ERR_OR_NULL(attach)) {
pr_err("dma_buf_attach failed\n");
+ rc = -EBADF;
goto err;
}
if (IS_ERR_OR_NULL(sg_table)) {
pr_err("dma_buf_map_attachment failed\n");
+ rc = -EBADF;
goto err;
}
int i, j, rc = 0;
dmabuf = dma_buf_get(fd);
- if (IS_ERR(dmabuf))
- return PTR_ERR(dmabuf);
+ if (IS_ERR_OR_NULL(dmabuf)) {
+ pr_err("dma_buf_get failed fd %d ret %pK\n", fd, dmabuf);
+ rc = -EBADF;
+ goto err;
+ }
attach = dma_buf_attach(dmabuf, hab_driver.dev);
if (IS_ERR_OR_NULL(attach)) {
pr_err("dma_buf_attach failed\n");
+ rc = -EBADF;
goto err;
}
if (IS_ERR_OR_NULL(sg_table)) {
pr_err("dma_buf_map_attachment failed\n");
+ rc = -EBADF;
goto err;
}