Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=3ba5619f06300cd0944150901ed20de87483ad8c
Commit:     3ba5619f06300cd0944150901ed20de87483ad8c
Parent:     c80e5ffac0579499ca28444155118ffcdd9b8d7e
Author:     Li Zefan <[EMAIL PROTECTED]>
AuthorDate: Wed Nov 14 11:31:05 2007 +0100
Committer:  Jiri Kosina <[EMAIL PROTECTED]>
CommitDate: Mon Jan 28 14:51:19 2008 +0100

    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 <[EMAIL PROTECTED]>
    Signed-off-by: Jiri Kosina <[EMAIL PROTECTED]>
---
 drivers/hid/usbhid/hid-tmff.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/usbhid/hid-tmff.c b/drivers/hid/usbhid/hid-tmff.c
index 69882a7..144578b 100644
--- a/drivers/hid/usbhid/hid-tmff.c
+++ b/drivers/hid/usbhid/hid-tmff.c
@@ -137,7 +137,8 @@ static int hid_tmff_play(struct input_dev *dev, void *data, 
struct ff_effect *ef
 int hid_tmff_init(struct hid_device *hid)
 {
        struct tmff_device *tmff;
-       struct list_head *pos;
+       struct hid_report *report;
+       struct list_head *report_list;
        struct hid_input *hidinput = list_entry(hid->inputs.next, struct 
hid_input, list);
        struct input_dev *input_dev = hidinput->input;
        const signed short *ff_bits = ff_joystick;
@@ -149,8 +150,8 @@ int hid_tmff_init(struct hid_device *hid)
                return -ENOMEM;
 
        /* Find the report to use */
-       list_for_each(pos, &hid->report_enum[HID_OUTPUT_REPORT].report_list) {
-               struct hid_report *report = (struct hid_report *)pos;
+       report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
+       list_for_each_entry(report, report_list, list) {
                int fieldnum;
 
                for (fieldnum = 0; fieldnum < report->maxfield; ++fieldnum) {
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to