提交 eeac8cda 编写于 作者: D Dan Carpenter 提交者: Martin K. Petersen

scsi: cxlflash: return -EFAULT if copy_from_user() fails

The copy_from/to_user() functions return the number of bytes remaining
to be copied but we had intended to return -EFAULT here.

Fixes: bc88ac47 ("scsi: cxlflash: Support AFU debug")
Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
Acked-by: NMatthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
上级 c57ec8fb
......@@ -3401,9 +3401,10 @@ static int cxlflash_afu_debug(struct cxlflash_cfg *cfg,
if (is_write) {
req_flags |= SISL_REQ_FLAGS_HOST_WRITE;
rc = copy_from_user(kbuf, ubuf, ulen);
if (unlikely(rc))
if (copy_from_user(kbuf, ubuf, ulen)) {
rc = -EFAULT;
goto out;
}
}
}
......@@ -3431,8 +3432,10 @@ static int cxlflash_afu_debug(struct cxlflash_cfg *cfg,
goto out;
}
if (ulen && !is_write)
rc = copy_to_user(ubuf, kbuf, ulen);
if (ulen && !is_write) {
if (copy_to_user(ubuf, kbuf, ulen))
rc = -EFAULT;
}
out:
kfree(buf);
dev_dbg(dev, "%s: returning rc=%d\n", __func__, rc);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册