Skip to content

Commit

Permalink
HID: picoLCD: prevent NULL pointer dereferences
Browse files Browse the repository at this point in the history
Driver code expects to get access to struct picolcd_data from hiddev
and is not prepared to find a NULL pointer there. Most prominent
candidate to trip on it is picolcd_fb_deferred_io().
Delay removing struct picolcd_data from hiddev until all sub-devices
have been unregistered.

Signed-off-by: Bruno Prémont <bonbons@linux-vserver.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Bruno Prémont authored and Jiri Kosina committed Sep 5, 2012
1 parent 9277738 commit a5785cc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/hid/hid-picolcd_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,6 @@ static void picolcd_remove(struct hid_device *hdev)
device_remove_file(&hdev->dev, &dev_attr_operation_mode_delay);
hid_hw_close(hdev);
hid_hw_stop(hdev);
hid_set_drvdata(hdev, NULL);

/* Shortcut potential pending reply that will never arrive */
spin_lock_irqsave(&data->lock, flags);
Expand All @@ -671,6 +670,7 @@ static void picolcd_remove(struct hid_device *hdev)
picolcd_exit_cir(data);
picolcd_exit_keys(data);

hid_set_drvdata(hdev, NULL);
mutex_destroy(&data->mutex);
/* Finally, clean up the picolcd data itself */
kfree(data);
Expand Down

0 comments on commit a5785cc

Please sign in to comment.