From d929dc2bfd8a58c34f1df0680018fa8ea5caa907 Mon Sep 17 00:00:00 2001 From: Kulikov Vasiliy Date: Tue, 10 Aug 2010 18:02:03 -0700 Subject: [PATCH] i2o: fix overflow of copy_to_user() If (len > reslen) we must not call copy_to_user() since kernel buffer is smaller than we want to copy. Similar code in this file is correct, so this bug was a typo. Signed-off-by: Kulikov Vasiliy Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/message/i2o/i2o_config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c index c4b117f5fb70..4dd39a03082a 100644 --- a/drivers/message/i2o/i2o_config.c +++ b/drivers/message/i2o/i2o_config.c @@ -115,7 +115,7 @@ static int i2o_cfg_gethrt(unsigned long arg) put_user(len, kcmd.reslen); if (len > reslen) ret = -ENOBUFS; - if (copy_to_user(kcmd.resbuf, (void *)hrt, len)) + else if (copy_to_user(kcmd.resbuf, (void *)hrt, len)) ret = -EFAULT; return ret; -- 2.20.1