[PATCH 05/18] HID: Improve two size determinations in hid_open_report()

From: SF Markus Elfring
Date: Tue Feb 07 2017 - 14:49:09 EST


From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 6 Feb 2017 22:00:07 +0100

Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
drivers/hid/hid-core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 404eccd0d670..16c73bf49d55 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -975,7 +975,7 @@ int hid_open_report(struct hid_device *device)
device->rdesc = start;
device->rsize = size;

- parser = vzalloc(sizeof(struct hid_parser));
+ parser = vzalloc(sizeof(*parser));
if (!parser) {
ret = -ENOMEM;
goto err;
@@ -986,7 +986,7 @@ int hid_open_report(struct hid_device *device)
end = start + size;

device->collection = kcalloc(HID_DEFAULT_NUM_COLLECTIONS,
- sizeof(struct hid_collection), GFP_KERNEL);
+ sizeof(*device->collection), GFP_KERNEL);
if (!device->collection) {
ret = -ENOMEM;
goto err;
--
2.11.1