mirror of
https://github.com/hardkernel/linux.git
synced 2026-03-25 03:50:24 +09:00
misc: genwqe: should return proper error value.
[ Upstream commit 02241995b0 ]
The function should return -EFAULT when copy_from_user fails. Even
though the caller does not distinguish them. but we should keep backward
compatibility.
Signed-off-by: zhong jiang <zhongjiang@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
4f15bdce67
commit
19d875ecbd
@@ -298,7 +298,7 @@ static int genwqe_sgl_size(int num_pages)
|
||||
int genwqe_alloc_sync_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl,
|
||||
void __user *user_addr, size_t user_size)
|
||||
{
|
||||
int rc;
|
||||
int ret = -ENOMEM;
|
||||
struct pci_dev *pci_dev = cd->pci_dev;
|
||||
|
||||
sgl->fpage_offs = offset_in_page((unsigned long)user_addr);
|
||||
@@ -317,7 +317,7 @@ int genwqe_alloc_sync_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl,
|
||||
if (get_order(sgl->sgl_size) > MAX_ORDER) {
|
||||
dev_err(&pci_dev->dev,
|
||||
"[%s] err: too much memory requested!\n", __func__);
|
||||
return -ENOMEM;
|
||||
return ret;
|
||||
}
|
||||
|
||||
sgl->sgl = __genwqe_alloc_consistent(cd, sgl->sgl_size,
|
||||
@@ -325,7 +325,7 @@ int genwqe_alloc_sync_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl,
|
||||
if (sgl->sgl == NULL) {
|
||||
dev_err(&pci_dev->dev,
|
||||
"[%s] err: no memory available!\n", __func__);
|
||||
return -ENOMEM;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Only use buffering on incomplete pages */
|
||||
@@ -338,7 +338,7 @@ int genwqe_alloc_sync_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl,
|
||||
/* Sync with user memory */
|
||||
if (copy_from_user(sgl->fpage + sgl->fpage_offs,
|
||||
user_addr, sgl->fpage_size)) {
|
||||
rc = -EFAULT;
|
||||
ret = -EFAULT;
|
||||
goto err_out;
|
||||
}
|
||||
}
|
||||
@@ -351,7 +351,7 @@ int genwqe_alloc_sync_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl,
|
||||
/* Sync with user memory */
|
||||
if (copy_from_user(sgl->lpage, user_addr + user_size -
|
||||
sgl->lpage_size, sgl->lpage_size)) {
|
||||
rc = -EFAULT;
|
||||
ret = -EFAULT;
|
||||
goto err_out2;
|
||||
}
|
||||
}
|
||||
@@ -373,7 +373,8 @@ int genwqe_alloc_sync_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl,
|
||||
sgl->sgl = NULL;
|
||||
sgl->sgl_dma_addr = 0;
|
||||
sgl->sgl_size = 0;
|
||||
return -ENOMEM;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int genwqe_setup_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl,
|
||||
|
||||
Reference in New Issue
Block a user