Skip to contentSkip to conversation

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)

PATCH New Dan Carpenter 1 participant 1 message Apr 9, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 304/324 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)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git  for-next
head:   857a80bbd7321161f986588160d97815d1b1206a
commit: ec504b23df9d33260602affc50389cf070707c9b [304/324] scsi: smartpqi: Add phy ID support for the physical drives
config: i386-randconfig-m021-20210406 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate

smatch warnings:
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)

vim +97 drivers/scsi/smartpqi/smartpqi_sas_transport.c

6c223761eb5482 Kevin Barnett 2016-06-27   88  static int pqi_sas_port_add_rphy(struct pqi_sas_port *pqi_sas_port,
6c223761eb5482 Kevin Barnett 2016-06-27   89  	struct sas_rphy *rphy)
6c223761eb5482 Kevin Barnett 2016-06-27   90  {
6c223761eb5482 Kevin Barnett 2016-06-27   91  	struct sas_identify *identify;
6c223761eb5482 Kevin Barnett 2016-06-27   92  
6c223761eb5482 Kevin Barnett 2016-06-27   93  	identify = &rphy->identify;
6c223761eb5482 Kevin Barnett 2016-06-27   94  	identify->sas_address = pqi_sas_port->sas_address;
ec504b23df9d33 Murthy Bhat   2021-03-11  @95  	identify->phy_identifier = pqi_sas_port->device->phy_id;
                                                                           ^^^^^^^^^^^^^^^^^^^^

New dereference

3d46a59a191e81 Don Brace 2018-12-07 96
3d46a59a191e81 Don Brace 2018-12-07 @97 if (pqi_sas_port->device &&

                                                    ^^^^^^^^^^^^^^^^^^^^

Checked too late.

3d46a59a191e81 Don Brace     2018-12-07   98  		pqi_sas_port->device->is_expander_smp_device) {
3d46a59a191e81 Don Brace     2018-12-07   99  		identify->initiator_port_protocols = SAS_PROTOCOL_SMP;
3d46a59a191e81 Don Brace     2018-12-07  100  		identify->target_port_protocols = SAS_PROTOCOL_SMP;
3d46a59a191e81 Don Brace     2018-12-07  101  	} else {
6c223761eb5482 Kevin Barnett 2016-06-27  102  		identify->initiator_port_protocols = SAS_PROTOCOL_STP;
6c223761eb5482 Kevin Barnett 2016-06-27  103  		identify->target_port_protocols = SAS_PROTOCOL_STP;
3d46a59a191e81 Don Brace     2018-12-07  104  	}
6c223761eb5482 Kevin Barnett 2016-06-27  105  
6c223761eb5482 Kevin Barnett 2016-06-27  106  	return sas_rphy_add(rphy);
6c223761eb5482 Kevin Barnett 2016-06-27  107  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

_______________________________________________
kbuild mailing list -- kbuild(a)lists.01.org
To unsubscribe send an email to kbuild-leave(a)lists.01.org