Skip to content

Commit 5cad5a5

Browse files
Don Bracemartinkpetersen
authored andcommitted
scsi: smartpqi: Fix device pointer variable reference static checker issue
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/[email protected]/msg06329.html Link: https://lore.kernel.org/r/161850493026.7302.10032784239320437353.stgit@brunhilda Fixes: ec504b2 ("scsi: smartpqi: Add phy ID support for the physical drives") Reported-by: Dan Carpenter <[email protected]> Reported-by: kernel test robot <[email protected]> Reviewed-by: Scott Benesh <[email protected]> Reviewed-by: Scott Teel <[email protected]> Reviewed-by: Mike McGowen <[email protected]> Reviewed-by: Kevin Barnett <[email protected]> Signed-off-by: Don Brace <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 667298c commit 5cad5a5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/scsi/smartpqi/smartpqi_sas_transport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ static int pqi_sas_port_add_rphy(struct pqi_sas_port *pqi_sas_port,
9292

9393
identify = &rphy->identify;
9494
identify->sas_address = pqi_sas_port->sas_address;
95-
identify->phy_identifier = pqi_sas_port->device->phy_id;
9695

9796
identify->initiator_port_protocols = SAS_PROTOCOL_ALL;
9897
identify->target_port_protocols = SAS_PROTOCOL_STP;
9998

10099
if (pqi_sas_port->device) {
100+
identify->phy_identifier = pqi_sas_port->device->phy_id;
101101
switch (pqi_sas_port->device->device_type) {
102102
case SA_DEVICE_TYPE_SAS:
103103
case SA_DEVICE_TYPE_SES:

0 commit comments

Comments
 (0)