aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/cxl/guest.c
diff options
context:
space:
mode:
authorVaibhav Jain <vaibhav@linux.ibm.com>2019-01-29 16:36:18 +0530
committerMichael Ellerman <mpe@ellerman.id.au>2019-01-30 23:36:53 +1100
commitedeb304f659792fb5bab90d7d6f3408b4c7301fb (patch)
treea5aca84df7ced12a90718d96abedda53747a572d /drivers/misc/cxl/guest.c
parentpowerpc/traps: Fix the message printed when stack overflows (diff)
downloadlinux-dev-edeb304f659792fb5bab90d7d6f3408b4c7301fb.tar.xz
linux-dev-edeb304f659792fb5bab90d7d6f3408b4c7301fb.zip
cxl: Wrap iterations over afu slices inside 'afu_list_lock'
Within cxl module, iteration over array 'adapter->afu' may be racy at few points as it might be simultaneously read during an EEH and its contents being set to NULL while driver is being unloaded or unbound from the adapter. This might result in a NULL pointer to 'struct afu' being de-referenced during an EEH thereby causing a kernel oops. This patch fixes this by making sure that all access to the array 'adapter->afu' is wrapped within the context of spin-lock 'adapter->afu_list_lock'. Fixes: 9e8df8a21963 ("cxl: EEH support") Cc: stable@vger.kernel.org # v4.3+ Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Acked-by: Frederic Barrat <fbarrat@linux.ibm.com> Acked-by: Christophe Lombard <clombard@linux.vnet.ibm.com> Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'drivers/misc/cxl/guest.c')
-rw-r--r--drivers/misc/cxl/guest.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/misc/cxl/guest.c b/drivers/misc/cxl/guest.c
index 5d28d9e454f5..08f4a512afad 100644
--- a/drivers/misc/cxl/guest.c
+++ b/drivers/misc/cxl/guest.c
@@ -267,6 +267,7 @@ static int guest_reset(struct cxl *adapter)
int i, rc;
pr_devel("Adapter reset request\n");
+ spin_lock(&adapter->afu_list_lock);
for (i = 0; i < adapter->slices; i++) {
if ((afu = adapter->afu[i])) {
pci_error_handlers(afu, CXL_ERROR_DETECTED_EVENT,
@@ -283,6 +284,7 @@ static int guest_reset(struct cxl *adapter)
pci_error_handlers(afu, CXL_RESUME_EVENT, 0);
}
}
+ spin_unlock(&adapter->afu_list_lock);
return rc;
}