switch: Reset device's drvdata before destroying it

dev_set_drvdata() sets the device specific driver data at
dev->p->driver_data.  However, dev is destroyed and has it's
context memory freed in device_destroy().  As a result, calling
dev_set_drvdata() causes a fault when accessing dev->p.

Change-Id: I4b1e6d17db52d0e31caf9b52e59979ff9cbb0c12
Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
This commit is contained in:
Deva Ramasubramanian 2013-02-06 11:29:25 -08:00 committed by Iliyan Malchev
parent a515e61bdc
commit 1d36299b6a

View file

@ -151,8 +151,8 @@ void switch_dev_unregister(struct switch_dev *sdev)
{
device_remove_file(sdev->dev, &dev_attr_name);
device_remove_file(sdev->dev, &dev_attr_state);
device_destroy(switch_class, MKDEV(0, sdev->index));
dev_set_drvdata(sdev->dev, NULL);
device_destroy(switch_class, MKDEV(0, sdev->index));
}
EXPORT_SYMBOL_GPL(switch_dev_unregister);