Skip to contentSkip to conversation

ipmi: ssif_bmc: Return -EFAULT if copy_from_user() fails

PATCH In review Dan Carpenter 2 participants 2 messages Jul 23, 2021

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

PATCH 1/1 ipmi: ssif_bmc: Return -EFAULT if copy_from_user() fails

The copy_from_user() function returns the number of bytes remaining to be copied but we should return -EFAULT here.

Fixes 007888f365c9 ("ipmi: ssif_bmc: Add SSIF BMC driver")
---
 drivers/char/ipmi/ssif_bmc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/char/ipmi/ssif_bmc.c +2 -3
index b15c05622e72..ce8cd8364a3f 100644
@@ -85,9 +85,8 @@ static ssize_t ssif_bmc_write(struct file *file, const char __user *buf, size_t
 	if (count > sizeof(struct ssif_msg))
 		return -EINVAL;
 
-	ret = copy_from_user(&msg, buf, count);
-	if (ret)
-		return ret;
+	if (copy_from_user(&msg, buf, count))
+		return -EFAULT;
 
 	if (!msg.len || count < ssif_msg_len(&msg))
 		return -EINVAL;
Signature · 1 line
2.20.1
#1 lore raw
Quoted 2 lines · Dan Carpenter

The copy_from_user() function returns the number of bytes remaining to be copied but we should return -EFAULT here.

Yep, this is in my queue.

Thanks,

-corey

Quoted 26 lines
Fixes 007888f365c9 ("ipmi: ssif_bmc: Add SSIF BMC driver")
---
 drivers/char/ipmi/ssif_bmc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/char/ipmi/ssif_bmc.c +2 -3
index b15c05622e72..ce8cd8364a3f 100644
@@ -85,9 +85,8 @@ static ssize_t ssif_bmc_write(struct file *file, const char __user *buf, size_t
 	if (count > sizeof(struct ssif_msg))
 		return -EINVAL;
 
-	ret = copy_from_user(&msg, buf, count);
-	if (ret)
-		return ret;
+	if (copy_from_user(&msg, buf, count))
+		return -EFAULT;
 
 	if (!msg.len || count < ssif_msg_len(&msg))
 		return -EINVAL;
Signature · 1 line
2.20.1