aboutsummaryrefslogtreecommitdiffstats
path: root/net/rfkill
diff options
context:
space:
mode:
Diffstat (limited to 'net/rfkill')
-rw-r--r--net/rfkill/core.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index 79693fe2001e..47497c97c8d9 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -1076,10 +1076,16 @@ static ssize_t rfkill_fop_write(struct file *file, const char __user *buf,
1076 struct rfkill_event ev; 1076 struct rfkill_event ev;
1077 1077
1078 /* we don't need the 'hard' variable but accept it */ 1078 /* we don't need the 'hard' variable but accept it */
1079 if (count < sizeof(ev) - 1) 1079 if (count < RFKILL_EVENT_SIZE_V1 - 1)
1080 return -EINVAL; 1080 return -EINVAL;
1081 1081
1082 if (copy_from_user(&ev, buf, sizeof(ev) - 1)) 1082 /*
1083 * Copy as much data as we can accept into our 'ev' buffer,
1084 * but tell userspace how much we've copied so it can determine
1085 * our API version even in a write() call, if it cares.
1086 */
1087 count = min(count, sizeof(ev));
1088 if (copy_from_user(&ev, buf, count))
1083 return -EFAULT; 1089 return -EFAULT;
1084 1090
1085 if (ev.op != RFKILL_OP_CHANGE && ev.op != RFKILL_OP_CHANGE_ALL) 1091 if (ev.op != RFKILL_OP_CHANGE && ev.op != RFKILL_OP_CHANGE_ALL)