*/
static int hid_scan_report(struct hid_device *hid)
{
- struct hid_parser *parser;
struct hid_item item;
const __u8 *start = hid->dev_rdesc;
const __u8 *end = start + hid->dev_rsize;
hid_parser_reserved
};
- parser = vzalloc(sizeof(struct hid_parser));
+ struct hid_parser *parser __free(kvfree) = vzalloc(sizeof(*parser));
if (!parser)
return -ENOMEM;
}
kfree(parser->collection_stack);
- vfree(parser);
return 0;
}
static int hid_parse_collections(struct hid_device *device)
{
- struct hid_parser *parser;
struct hid_item item;
const u8 *start = device->rdesc;
const u8 *end = start + device->rsize;
hid_parser_reserved
};
- parser = vzalloc(sizeof(*parser));
+ struct hid_parser *parser __free(kvfree) = vzalloc(sizeof(*parser));
if (!parser)
return -ENOMEM;
device->collection = kzalloc_objs(*device->collection,
HID_DEFAULT_NUM_COLLECTIONS);
- if (!device->collection) {
- ret = -ENOMEM;
- goto out;
- }
+ if (!device->collection)
+ return -ENOMEM;
+
device->collection_size = HID_DEFAULT_NUM_COLLECTIONS;
for (unsigned int i = 0; i < HID_DEFAULT_NUM_COLLECTIONS; i++)
device->collection[i].parent_idx = -1;
out:
kfree(parser->collection_stack);
- vfree(parser);
return ret;
}
* on a copy of our report descriptor so it can
* change it.
*/
- __u8 *buf = kmemdup(start, size, GFP_KERNEL);
+ u8 *buf __free(kfree) = kmemdup(start, size, GFP_KERNEL);
- if (buf == NULL)
+ if (!buf)
return -ENOMEM;
start = device->driver->report_fixup(device, buf, &size);
* needs to be cleaned up or not at the end.
*/
start = kmemdup(start, size, GFP_KERNEL);
- kfree(buf);
- if (start == NULL)
+ if (!start)
return -ENOMEM;
}
int __hid_request(struct hid_device *hid, struct hid_report *report,
enum hid_class_request reqtype)
{
- char *buf, *data_buf;
+ u8 *data_buf;
int ret;
u32 len;
- buf = hid_alloc_report_buf(report, GFP_KERNEL);
+ u8 *buf __free(kfree) = hid_alloc_report_buf(report, GFP_KERNEL);
if (!buf)
return -ENOMEM;
ret = hid_hw_raw_request(hid, report->id, buf, len, report->type, reqtype);
if (ret < 0) {
dbg_hid("unable to complete request: %d\n", ret);
- goto out;
+ return ret;
}
if (reqtype == HID_REQ_GET_REPORT)
hid_input_report(hid, report->type, buf, ret, 0);
- ret = 0;
-
-out:
- kfree(buf);
- return ret;
+ return 0;
}
EXPORT_SYMBOL_GPL(__hid_request);