From: Dan Carpenter Date: Fri, 14 Apr 2017 19:11:53 +0000 (+0300) Subject: orangefs: handle zero size write in debugfs X-Git-Tag: v4.12-rc1~89^2~3 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;ds=sidebyside;h=907bfcd8d8a616ca794ba187f6bf1b0e12b3a8dd;p=karo-tx-linux.git orangefs: handle zero size write in debugfs If we write zero bytes to this debugfs file, then it will cause an underflow when we do copy_from_user(buf, ubuf, count - 1). Debugfs can normally only be written to by root so the impact of this is low. Signed-off-by: Dan Carpenter Signed-off-by: Mike Marshall --- diff --git a/fs/orangefs/orangefs-debugfs.c b/fs/orangefs/orangefs-debugfs.c index 791912da97d7..716ed337f166 100644 --- a/fs/orangefs/orangefs-debugfs.c +++ b/fs/orangefs/orangefs-debugfs.c @@ -440,6 +440,9 @@ static ssize_t orangefs_debug_write(struct file *file, "orangefs_debug_write: %pD\n", file); + if (count == 0) + return 0; + /* * Thwart users who try to jamb a ridiculous number * of bytes into the debug file...