Skip to content

Commit ea641be

Browse files
zhangjian3032cminyard
authored andcommitted
ipmi: ssif_bmc: fix missing check for copy_to_user() partial failure
copy_to_user() returns the number of bytes that could not be copied, with a non-zero value indicating a partial or complete failure. The current code only checks for negative return values and treats all non-negative results as success. Treating any positive return value from copy_to_user() as an error and returning -EFAULT. Fixes: dd2bc5c ("ipmi: ssif_bmc: Add SSIF BMC driver") Signed-off-by: Jian Zhang <zhangjian.3032@bytedance.com> Message-ID: <20260403090603.3988423-2-zhangjian.3032@bytedance.com> Signed-off-by: Corey Minyard <corey@minyard.net>
1 parent 7fc3e25 commit ea641be

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/char/ipmi/ssif_bmc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ static ssize_t ssif_bmc_read(struct file *file, char __user *buf, size_t count,
163163
spin_unlock_irqrestore(&ssif_bmc->lock, flags);
164164

165165
ret = copy_to_user(buf, &msg, count);
166+
if (ret > 0)
167+
ret = -EFAULT;
166168
}
167169

168170
return (ret < 0) ? ret : count;

0 commit comments

Comments
 (0)