Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 68764
b: refs/heads/master
c: 57d292b
h: refs/heads/master
v: v3
  • Loading branch information
Jiri Kosina authored and Linus Torvalds committed Oct 15, 2007
1 parent 8f2c8e1 commit 3eb75f5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 23fd50450a34f2558070ceabb0bfebc1c9604af5
refs/heads/master: 57d292bd7e6e72898e533687af481603597b1ca7
12 changes: 9 additions & 3 deletions trunk/drivers/hid/hidraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,15 @@ static int hidraw_ioctl(struct inode *inode, struct file *file, unsigned int cmd

if (get_user(len, (int __user *)arg))
return -EFAULT;
if (copy_to_user(*((__u8 **)(user_arg +
sizeof(__u32))),
dev->hid->rdesc, len))

if (len > HID_MAX_DESCRIPTOR_SIZE - 1)
return -EINVAL;

if (copy_to_user(user_arg + offsetof(
struct hidraw_report_descriptor,
value[0]),
dev->hid->rdesc,
min(dev->hid->rsize, len)))
return -EFAULT;
return 0;
}
Expand Down
20 changes: 12 additions & 8 deletions trunk/include/linux/hid.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@
* Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
*/

#include <linux/types.h>
#include <linux/slab.h>
#include <linux/list.h>
#include <linux/timer.h>
#include <linux/workqueue.h>
#include <linux/input.h>

/*
* USB HID (Human Interface Device) interface class code
*/
Expand Down Expand Up @@ -69,6 +62,17 @@
#define HID_DT_REPORT (USB_TYPE_CLASS | 0x02)
#define HID_DT_PHYSICAL (USB_TYPE_CLASS | 0x03)

#define HID_MAX_DESCRIPTOR_SIZE 4096

#ifdef __KERNEL__

#include <linux/types.h>
#include <linux/slab.h>
#include <linux/list.h>
#include <linux/timer.h>
#include <linux/workqueue.h>
#include <linux/input.h>

/*
* We parse each description item into this structure. Short items data
* values are expanded to 32-bit signed int, long items contain a pointer
Expand Down Expand Up @@ -311,7 +315,6 @@ struct hid_global {
* This is the local environment. It is persistent up the next main-item.
*/

#define HID_MAX_DESCRIPTOR_SIZE 4096
#define HID_MAX_USAGES 8192
#define HID_DEFAULT_NUM_COLLECTIONS 16

Expand Down Expand Up @@ -560,4 +563,5 @@ static inline int hid_ff_init(struct hid_device *hid) { return -1; }
#define err_hid(format, arg...) printk(KERN_ERR "%s: " format "\n" , \
__FILE__ , ## arg)
#endif
#endif

6 changes: 3 additions & 3 deletions trunk/include/linux/hidraw.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include <linux/hid.h>

struct hidraw_report_descriptor {
__u32 size;
__u8 *value;
__u8 value[HID_MAX_DESCRIPTOR_SIZE];
};

struct hidraw_devinfo {
Expand All @@ -40,8 +42,6 @@ struct hidraw_devinfo {
/* kernel-only API declarations */
#ifdef __KERNEL__

#include <linux/hid.h>

struct hidraw {
unsigned int minor;
int exist;
Expand Down

0 comments on commit 3eb75f5

Please sign in to comment.