mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-07 19:49:33 -04:00
scsi: mpt3sas: Fix a locking bug in an error path
Call mutex_unlock(&ioc->hostdiag_unlock_mutex) once from error paths
instead of twice.
This patch fixes the following Clang -Wthread-safety errors:
drivers/scsi/mpt3sas/mpt3sas_base.c:8085:2: error: mutex 'ioc->hostdiag_unlock_mutex' is not held on every path through here [-Werror,-Wthread-safety-analysis]
8085 | pci_cfg_access_unlock(ioc->pdev);
| ^
drivers/scsi/mpt3sas/mpt3sas_base.c:8019:2: note: mutex acquired here
8019 | mutex_lock(&ioc->hostdiag_unlock_mutex);
| ^
./include/linux/mutex.h:171:26: note: expanded from macro 'mutex_lock'
171 | #define mutex_lock(lock) mutex_lock_nested(lock, 0)
| ^
drivers/scsi/mpt3sas/mpt3sas_base.c:8085:2: error: mutex 'ioc->hostdiag_unlock_mutex' is not held on every path through here [-Werror,-Wthread-safety-analysis]
8085 | pci_cfg_access_unlock(ioc->pdev);
| ^
drivers/scsi/mpt3sas/mpt3sas_base.c:8019:2: note: mutex acquired here
8019 | mutex_lock(&ioc->hostdiag_unlock_mutex);
| ^
./include/linux/mutex.h:171:26: note: expanded from macro 'mutex_lock'
171 | #define mutex_lock(lock) mutex_lock_nested(lock, 0)
| ^
drivers/scsi/mpt3sas/mpt3sas_base.c:8087:2: error: releasing mutex 'ioc->hostdiag_unlock_mutex' that was not held [-Werror,-Wthread-safety-analysis]
8087 | mutex_unlock(&ioc->hostdiag_unlock_mutex);
| ^
Cc: Ranjan Kumar <ranjan.kumar@broadcom.com>
Fixes: c0767560b0 ("scsi: mpt3sas: Reload SBR without rebooting HBA")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20250210203936.2946494-3-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
committed by
Martin K. Petersen
parent
c733741ae1
commit
38afcf0660
@@ -8018,7 +8018,7 @@ _base_diag_reset(struct MPT3SAS_ADAPTER *ioc)
|
||||
|
||||
mutex_lock(&ioc->hostdiag_unlock_mutex);
|
||||
if (mpt3sas_base_unlock_and_get_host_diagnostic(ioc, &host_diagnostic))
|
||||
goto out;
|
||||
goto unlock;
|
||||
|
||||
hcb_size = ioc->base_readl(&ioc->chip->HCBSize);
|
||||
drsprintk(ioc, ioc_info(ioc, "diag reset: issued\n"));
|
||||
@@ -8038,7 +8038,7 @@ _base_diag_reset(struct MPT3SAS_ADAPTER *ioc)
|
||||
ioc_info(ioc,
|
||||
"Invalid host diagnostic register value\n");
|
||||
_base_dump_reg_set(ioc);
|
||||
goto out;
|
||||
goto unlock;
|
||||
}
|
||||
if (!(host_diagnostic & MPI2_DIAG_RESET_ADAPTER))
|
||||
break;
|
||||
@@ -8074,17 +8074,19 @@ _base_diag_reset(struct MPT3SAS_ADAPTER *ioc)
|
||||
ioc_err(ioc, "%s: failed going to ready state (ioc_state=0x%x)\n",
|
||||
__func__, ioc_state);
|
||||
_base_dump_reg_set(ioc);
|
||||
goto out;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
pci_cfg_access_unlock(ioc->pdev);
|
||||
ioc_info(ioc, "diag reset: SUCCESS\n");
|
||||
return 0;
|
||||
|
||||
out:
|
||||
unlock:
|
||||
mutex_unlock(&ioc->hostdiag_unlock_mutex);
|
||||
|
||||
fail:
|
||||
pci_cfg_access_unlock(ioc->pdev);
|
||||
ioc_err(ioc, "diag reset: FAILED\n");
|
||||
mutex_unlock(&ioc->hostdiag_unlock_mutex);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user