intel_scu_ipc: Protect dev member assignment on ->remove()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 12 Oct 2015 11:19:48 +0000 (14:19 +0300)
committerDarren Hart <dvhart@linux.intel.com>
Thu, 15 Oct 2015 15:23:30 +0000 (08:23 -0700)
Protect the dev member assignment in ->remove() since user may potentially call
unbind from a sysfs even if the driver is built-in. The latter might be racy
with ongoing SCU communication.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
drivers/platform/x86/intel_scu_ipc.c

index 9de2029aa909fff71bb3301c7d95c386bb5ed2b3..f94b730540e240334e5fe631bd9f60997f0b2dbc 100644 (file)
@@ -625,7 +625,10 @@ static void ipc_remove(struct pci_dev *pdev)
 {
        struct intel_scu_ipc_dev *scu = pci_get_drvdata(pdev);
 
+       mutex_lock(&ipclock);
        scu->dev = NULL;
+       mutex_unlock(&ipclock);
+
        iounmap(scu->i2c_base);
        intel_scu_devices_destroy();
 }