@@ -65,6 +65,10 @@ static int betop_probe(struct hid_device *hdev, const struct hid_device_id *id)
int error;
int i, j;
+ betopff = devm_kzalloc(&hdev->dev, sizeof(*betopff), GFP_KERNEL);
+ if (!betopff)
+ return -ENOMEM;
+
if (id->driver_data)
hdev->quirks |= HID_QUIRK_MULTI_INPUT;
@@ -108,17 +112,12 @@ static int betop_probe(struct hid_device *hdev, const struct hid_device_id *id)
return -ENODEV;
}
- betopff = kzalloc(sizeof(*betopff), GFP_KERNEL);
- if (!betopff)
- return -ENOMEM;
-
hidinput = list_first_entry(&hdev->inputs, struct hid_input, list);
set_bit(FF_RUMBLE, hidinput->input->ffbit);
error = input_ff_create_memless(hidinput->input,
betopff, hid_betopff_play);
if (error) {
- kfree(betopff);
return error;
}
HID: hid-betopff.c: Allocate mem before hid_parse, use devm_kzalloc() The driver's betopff struct should be allocated prior to parsing. With devm_kzalloc() the use of kfree() turns obsolete and error handling is simplified. Signed-off-by: Hanno Zulla <kontakt@hanno.de> --- drivers/hid/hid-betopff.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)