pps: Fix a use-after free bug when unregistering a source.
authorGeorge Spelvin <linux@horizon.com>
Tue, 12 Feb 2013 07:27:20 +0000 (02:27 -0500)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 6 Mar 2013 03:23:58 +0000 (03:23 +0000)
commit77327a71f9841b7dfa708195d1cb133d4ef4a989
tree8e8409bcbf4c3eff84080a9617289d9d2e36e02e
parent24625640fe278feac753e36888ff1d335d39964b
pps: Fix a use-after free bug when unregistering a source.

commit d953e0e837e65ecc1ddaa4f9560f7925878a0de6 upstream.

Remove the cdev from the system (with cdev_del) *before* deallocating it
(in pps_device_destruct, called via kobject_put from device_destroy).

Also prevent deallocating a device with open file handles.

A better long-term fix is probably to remove the cdev from the pps_device
entirely, and instead have all devices reference one global cdev.  Then
the deallocation ordering becomes simpler.

But that's more complex and invasive change, so we leave that
for later.

Signed-off-by: George Spelvin <linux@horizon.com>
Acked-by: Rodolfo Giometti <giometti@enneenne.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/pps/pps.c