aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/input/hid-core.c
diff options
context:
space:
mode:
authorOliver Neukum <oliver@neukum.org>2006-01-06 14:54:29 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-03-20 17:49:52 -0500
commitbbdb7dafb5b5a3c0197cbabd5055d8e9c093e3ea (patch)
tree9ac23c97ef6a983e4e7a98e19f9307b8d3aad1f4 /drivers/usb/input/hid-core.c
parent887c2560b6ceb5fe7ac24704e85af507c6d960e5 (diff)
[PATCH] USB: kzalloc for hid
this uses kzalloc in hid. Signed-off-by: Oliver Neukum <oliver@neukum.name> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/input/hid-core.c')
-rw-r--r--drivers/usb/input/hid-core.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index 07a012f88772..f187a719f17e 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -66,9 +66,8 @@ static struct hid_report *hid_register_report(struct hid_device *device, unsigne
66 if (report_enum->report_id_hash[id]) 66 if (report_enum->report_id_hash[id])
67 return report_enum->report_id_hash[id]; 67 return report_enum->report_id_hash[id];
68 68
69 if (!(report = kmalloc(sizeof(struct hid_report), GFP_KERNEL))) 69 if (!(report = kzalloc(sizeof(struct hid_report), GFP_KERNEL)))
70 return NULL; 70 return NULL;
71 memset(report, 0, sizeof(struct hid_report));
72 71
73 if (id != 0) 72 if (id != 0)
74 report_enum->numbered = 1; 73 report_enum->numbered = 1;
@@ -97,12 +96,9 @@ static struct hid_field *hid_register_field(struct hid_report *report, unsigned
97 return NULL; 96 return NULL;
98 } 97 }
99 98
100 if (!(field = kmalloc(sizeof(struct hid_field) + usages * sizeof(struct hid_usage) 99 if (!(field = kzalloc(sizeof(struct hid_field) + usages * sizeof(struct hid_usage)
101 + values * sizeof(unsigned), GFP_KERNEL))) return NULL; 100 + values * sizeof(unsigned), GFP_KERNEL))) return NULL;
102 101
103 memset(field, 0, sizeof(struct hid_field) + usages * sizeof(struct hid_usage)
104 + values * sizeof(unsigned));
105
106 field->index = report->maxfield++; 102 field->index = report->maxfield++;
107 report->field[field->index] = field; 103 report->field[field->index] = field;
108 field->usage = (struct hid_usage *)(field + 1); 104 field->usage = (struct hid_usage *)(field + 1);
@@ -651,17 +647,14 @@ static struct hid_device *hid_parse_report(__u8 *start, unsigned size)
651 hid_parser_reserved 647 hid_parser_reserved
652 }; 648 };
653 649
654 if (!(device = kmalloc(sizeof(struct hid_device), GFP_KERNEL))) 650 if (!(device = kzalloc(sizeof(struct hid_device), GFP_KERNEL)))
655 return NULL; 651 return NULL;
656 memset(device, 0, sizeof(struct hid_device));
657 652
658 if (!(device->collection = kmalloc(sizeof(struct hid_collection) * 653 if (!(device->collection = kzalloc(sizeof(struct hid_collection) *
659 HID_DEFAULT_NUM_COLLECTIONS, GFP_KERNEL))) { 654 HID_DEFAULT_NUM_COLLECTIONS, GFP_KERNEL))) {
660 kfree(device); 655 kfree(device);
661 return NULL; 656 return NULL;
662 } 657 }
663 memset(device->collection, 0, sizeof(struct hid_collection) *
664 HID_DEFAULT_NUM_COLLECTIONS);
665 device->collection_size = HID_DEFAULT_NUM_COLLECTIONS; 658 device->collection_size = HID_DEFAULT_NUM_COLLECTIONS;
666 659
667 for (i = 0; i < HID_REPORT_TYPES; i++) 660 for (i = 0; i < HID_REPORT_TYPES; i++)
@@ -675,13 +668,12 @@ static struct hid_device *hid_parse_report(__u8 *start, unsigned size)
675 memcpy(device->rdesc, start, size); 668 memcpy(device->rdesc, start, size);
676 device->rsize = size; 669 device->rsize = size;
677 670
678 if (!(parser = kmalloc(sizeof(struct hid_parser), GFP_KERNEL))) { 671 if (!(parser = kzalloc(sizeof(struct hid_parser), GFP_KERNEL))) {
679 kfree(device->rdesc); 672 kfree(device->rdesc);
680 kfree(device->collection); 673 kfree(device->collection);
681 kfree(device); 674 kfree(device);
682 return NULL; 675 return NULL;
683 } 676 }
684 memset(parser, 0, sizeof(struct hid_parser));
685 parser->device = device; 677 parser->device = device;
686 678
687 end = start + size; 679 end = start + size;