Skip to contentSkip to conversation

scsi: lpfc: Fix some error codes in debugfs

PATCH Applied Dan Carpenter 2 participants 2 messages Mar 12, 2021 – Mar 16, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: lpfc: Fix some error codes in debugfs

If copy_from_user() or kstrtoull() fail then the correct behavior is to return a negative error code.

Fixes f9bb2da11db8 ("[SCSI] lpfc 8.3.27: T10 additions for SLI4")
---
 drivers/scsi/lpfc/lpfc_debugfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/lpfc/lpfc_debugfs.c +2 -2
index ec5328f7f1d4..c69c2dbfc470 100644
@@ -2424,7 +2424,7 @@ lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf,
 	memset(dstbuf, 0, 33);
 	size = (nbytes < 32) ? nbytes : 32;
 	if (copy_from_user(dstbuf, buf, size))
-		return 0;
+		return -EFAULT;
 
 	if (dent == phba->debug_InjErrLBA) {
 		if ((dstbuf[0] == 'o') && (dstbuf[1] == 'f') &&
@@ -2433,7 +2433,7 @@ lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf,
 	}
 
 	if ((tmp == 0) && (kstrtoull(dstbuf, 0, &tmp)))
-		return 0;
+		return -EINVAL;
 
 	if (dent == phba->debug_writeGuard)
 		phba->lpfc_injerr_wgrd_cnt = (uint32_t)tmp;
Signature · 1 line
2.30.1
#1 lore raw
Quoted 2 lines · Dan Carpenter

If copy_from_user() or kstrtoull() fail then the correct behavior is to return a negative error code.

Applied to 5.12/scsi-fixes, thanks!

[1/1] scsi: lpfc: Fix some error codes in debugfs

      https://git.kernel.org/mkp/scsi/c/19f1bc7edf0f
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering