[<prev] [next>] [day] [month] [year] [list]
Message-Id: <f74754f0d7d870ac8301eb8f5760d473bdd0270b.1731492709.git.xiaopei01@kylinos.cn>
Date: Wed, 13 Nov 2024 18:13:42 +0800
From: Pei Xiao <xiaopei01@...inos.cn>
To: jikos@...nel.org,
bentiss@...nel.org,
linux-input@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: xiaopeitux@...mail.com,
Pei Xiao <xiaopei01@...inos.cn>,
syzbot+3fa2af55f15bd21cada9@...kaller.appspotmail.com
Subject: [PATCH] HID: core: s32ton always be 0 when n>=32
s32ton always be 0 when n>=32,add check n.
Reported-by: syzbot+3fa2af55f15bd21cada9@...kaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=3fa2af55f15bd21cada9
Fixes: c653ffc28340 ("HID: stop exporting hid_snto32()")
Signed-off-by: Pei Xiao <xiaopei01@...inos.cn>
---
drivers/hid/hid-core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 81d6c734c8bc..ead1d338fa58 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -66,8 +66,11 @@ static s32 snto32(__u32 value, unsigned int n)
static u32 s32ton(__s32 value, unsigned int n)
{
- s32 a = value >> (n - 1);
+ s32 a;
+ if (n >= 32)
+ return value;
+ a = value >> (n - 1);
if (a && a != -1)
return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1;
return value & ((1 << n) - 1);
--
2.34.1
Powered by blists - more mailing lists