[PATCH][SRU][F-hwe-5.11 29/30] scsi: smartpqi: Fix device pointer variable reference static checker issue
Krzysztof Kozlowski
krzysztof.kozlowski at canonical.com
Thu Jul 1 06:51:40 UTC 2021
From: Don Brace <don.brace at microchip.com>
BugLink: https://bugs.launchpad.net/bugs/1933518
Dan Carpenter found a possible NULL pointer dereference issue in function
pqi_sas_port_add_rphy():
drivers/scsi/smartpqi/smartpqi_sas_transport.c:97
pqi_sas_port_add_rphy() warn: variable dereferenced before
check 'pqi_sas_port->device' (see line 95)
Correct issue by moving reference of pqi_sas_port->device after the check
for the device pointer being non-NULL.
Link: https://www.mail-archive.com/kbuild@lists.01.org/msg06329.html
Link: https://lore.kernel.org/r/161850493026.7302.10032784239320437353.stgit@brunhilda
Fixes: ec504b23df9d ("scsi: smartpqi: Add phy ID support for the physical drives")
Reported-by: Dan Carpenter <dan.carpenter at oracle.com>
Reported-by: kernel test robot <lkp at intel.com>
Reviewed-by: Scott Benesh <scott.benesh at microchip.com>
Reviewed-by: Scott Teel <scott.teel at microchip.com>
Reviewed-by: Mike McGowen <mike.mcgowen at microchip.com>
Reviewed-by: Kevin Barnett <kevin.barnett at microchip.com>
Signed-off-by: Don Brace <don.brace at microchip.com>
Signed-off-by: Martin K. Petersen <martin.petersen at oracle.com>
(cherry picked from commit 5cad5a507241b4b72b7cad27cf769ac645e53d45)
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski at canonical.com>
---
drivers/scsi/smartpqi/smartpqi_sas_transport.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/smartpqi/smartpqi_sas_transport.c b/drivers/scsi/smartpqi/smartpqi_sas_transport.c
index dd9b784792ef..dd628cc87f78 100644
--- a/drivers/scsi/smartpqi/smartpqi_sas_transport.c
+++ b/drivers/scsi/smartpqi/smartpqi_sas_transport.c
@@ -92,12 +92,12 @@ static int pqi_sas_port_add_rphy(struct pqi_sas_port *pqi_sas_port,
identify = &rphy->identify;
identify->sas_address = pqi_sas_port->sas_address;
- identify->phy_identifier = pqi_sas_port->device->phy_id;
identify->initiator_port_protocols = SAS_PROTOCOL_ALL;
identify->target_port_protocols = SAS_PROTOCOL_STP;
if (pqi_sas_port->device) {
+ identify->phy_identifier = pqi_sas_port->device->phy_id;
switch (pqi_sas_port->device->device_type) {
case SA_DEVICE_TYPE_SAS:
case SA_DEVICE_TYPE_SES:
--
2.27.0
More information about the kernel-team
mailing list