]> git.baikalelectronics.ru Git - kernel.git/commit
HID: fix a potential bug in pointer casting
authorLi Zefan <lizf@cn.fujitsu.com>
Wed, 14 Nov 2007 10:31:05 +0000 (11:31 +0100)
committerJiri Kosina <jkosina@suse.cz>
Mon, 28 Jan 2008 13:51:19 +0000 (14:51 +0100)
commit132868e0b263d22d319a158e29a02701c9f91aea
tree2fab950f6766fc7c5d2242ac6063ee92c4e8e546
parentcd79d0b79542e1b08ced5d3ddc4812233b437a52
HID: fix a potential bug in pointer casting

Don't directly cast list_head * to foo *, this works only when list
is the first member of struct foo, and we should not make the assumption
how members are ordered in the structure.

i.e. struct *f = (struct *f)pos will work if:
struct foo {
struct list_head list;
int i;
};

but will fail if:
struct foo {
int i;
struct list_head list;
}

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/usbhid/hid-tmff.c