]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ipmi: ssif_bmc: fix missing check for copy_to_user() partial failure
authorJian Zhang <zhangjian.3032@bytedance.com>
Fri, 3 Apr 2026 09:05:59 +0000 (17:05 +0800)
committerCorey Minyard <corey@minyard.net>
Fri, 3 Apr 2026 12:49:53 +0000 (07:49 -0500)
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: dd2bc5cc9e25 ("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>
drivers/char/ipmi/ssif_bmc.c

index dc1d5bb4a460446a8e991f96acde01b6b05a7417..fbc7d2cfd5351ced0fffe218b79b482eb6cfe09e 100644 (file)
@@ -163,6 +163,8 @@ static ssize_t ssif_bmc_read(struct file *file, char __user *buf, size_t count,
                spin_unlock_irqrestore(&ssif_bmc->lock, flags);
 
                ret = copy_to_user(buf, &msg, count);
+               if (ret > 0)
+                       ret = -EFAULT;
        }
 
        return (ret < 0) ? ret : count;