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: bc88ac47d5 ("scsi: cxlflash: Support AFU debug")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Dan Carpenter 2017-06-30 11:01:06 +03:00 committed by Martin K. Petersen
parent c57ec8fb7c
commit eeac8cda2c

View file

@ -3401,9 +3401,10 @@ static int cxlflash_afu_debug(struct cxlflash_cfg *cfg,
if (is_write) { if (is_write) {
req_flags |= SISL_REQ_FLAGS_HOST_WRITE; req_flags |= SISL_REQ_FLAGS_HOST_WRITE;
rc = copy_from_user(kbuf, ubuf, ulen); if (copy_from_user(kbuf, ubuf, ulen)) {
if (unlikely(rc)) rc = -EFAULT;
goto out; goto out;
}
} }
} }
@ -3431,8 +3432,10 @@ static int cxlflash_afu_debug(struct cxlflash_cfg *cfg,
goto out; goto out;
} }
if (ulen && !is_write) if (ulen && !is_write) {
rc = copy_to_user(ubuf, kbuf, ulen); if (copy_to_user(ubuf, kbuf, ulen))
rc = -EFAULT;
}
out: out:
kfree(buf); kfree(buf);
dev_dbg(dev, "%s: returning rc=%d\n", __func__, rc); dev_dbg(dev, "%s: returning rc=%d\n", __func__, rc);