Skip to content

Commit 789a2c2

Browse files
Hanno Zullabentiss
authored andcommitted
HID: hid-bigbenff: fix general protection fault caused by double kfree
The struct *bigben was allocated via devm_kzalloc() and then used as a parameter in input_ff_create_memless(). This caused a double kfree during removal of the device, since both the managed resource API and ml_ff_destroy() in drivers/input/ff-memless.c would call kfree() on it. Signed-off-by: Hanno Zulla <[email protected]> Signed-off-by: Benjamin Tissoires <[email protected]>
1 parent be0aba8 commit 789a2c2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/hid/hid-bigbenff.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,16 @@ static void bigben_worker(struct work_struct *work)
220220
static int hid_bigben_play_effect(struct input_dev *dev, void *data,
221221
struct ff_effect *effect)
222222
{
223-
struct bigben_device *bigben = data;
223+
struct hid_device *hid = input_get_drvdata(dev);
224+
struct bigben_device *bigben = hid_get_drvdata(hid);
224225
u8 right_motor_on;
225226
u8 left_motor_force;
226227

228+
if (!bigben) {
229+
hid_err(hid, "no device data\n");
230+
return 0;
231+
}
232+
227233
if (effect->type != FF_RUMBLE)
228234
return 0;
229235

@@ -341,7 +347,7 @@ static int bigben_probe(struct hid_device *hid,
341347

342348
INIT_WORK(&bigben->worker, bigben_worker);
343349

344-
error = input_ff_create_memless(hidinput->input, bigben,
350+
error = input_ff_create_memless(hidinput->input, NULL,
345351
hid_bigben_play_effect);
346352
if (error)
347353
return error;

0 commit comments

Comments
 (0)