[xilinx-xlnx:xlnx_rebase_v5.15 72/872] drivers/mtd/spi-nor/core.c:1891 spi_nor_read_id() error: we previously assumed 'nor->spimem' could be null (see line 1873)

Dan Carpenter dan.carpenter at oracle.com
Mon Feb 7 22:31:28 PST 2022


tree:   https://github.com/Xilinx/linux-xlnx xlnx_rebase_v5.15
head:   1183ce490adb103e5e569b8ebd74c50c885ddc05
commit: 87a0aa695a2dbabc2d1a24acbb421529ea53c59e [72/872] spi: spi-cadence-quadspi: Add support for DDR PHY mode
config: x86_64-randconfig-m001-20220207 (https://download.01.org/0day-ci/archive/20220208/202202081251.fIdJevWf-lkp@intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp at intel.com>
Reported-by: Dan Carpenter <dan.carpenter at oracle.com>

smatch warnings:
drivers/mtd/spi-nor/core.c:1891 spi_nor_read_id() error: we previously assumed 'nor->spimem' could be null (see line 1873)

vim +1891 drivers/mtd/spi-nor/core.c

06bb6f5a69dfc5 drivers/mtd/spi-nor/spi-nor.c Rafał Miłecki        2015-08-10  1866  static const struct flash_info *spi_nor_read_id(struct spi_nor *nor)
b199489d37b21c drivers/mtd/spi-nor/spi-nor.c Huang Shijie         2014-02-24  1867  {
9ec4bbcb2044ea drivers/mtd/spi-nor/core.c    Boris Brezillon      2020-03-13  1868  	const struct flash_info *info;
f173f26a4d543f drivers/mtd/spi-nor/spi-nor.c Vignesh Raghavendra  2019-08-06  1869  	u8 *id = nor->bouncebuf;
2dcbfe365b1303 drivers/mtd/spi-nor/spi-nor.c Jonathan Neuschäfer  2020-02-23  1870  	unsigned int i;
2dcbfe365b1303 drivers/mtd/spi-nor/spi-nor.c Jonathan Neuschäfer  2020-02-23  1871  	int ret;
b199489d37b21c drivers/mtd/spi-nor/spi-nor.c Huang Shijie         2014-02-24  1872  
b35b9a10362d20 drivers/mtd/spi-nor/spi-nor.c Boris Brezillon      2019-08-06 @1873  	if (nor->spimem) {
                                                                                            ^^^^^^^^^^^
Check for NULL

b35b9a10362d20 drivers/mtd/spi-nor/spi-nor.c Boris Brezillon      2019-08-06  1874  		struct spi_mem_op op =
b35b9a10362d20 drivers/mtd/spi-nor/spi-nor.c Boris Brezillon      2019-08-06  1875  			SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RDID, 1),
b35b9a10362d20 drivers/mtd/spi-nor/spi-nor.c Boris Brezillon      2019-08-06  1876  				   SPI_MEM_OP_NO_ADDR,
b35b9a10362d20 drivers/mtd/spi-nor/spi-nor.c Boris Brezillon      2019-08-06  1877  				   SPI_MEM_OP_NO_DUMMY,
b35b9a10362d20 drivers/mtd/spi-nor/spi-nor.c Boris Brezillon      2019-08-06  1878  				   SPI_MEM_OP_DATA_IN(SPI_NOR_MAX_ID_LEN, id, 1));
b35b9a10362d20 drivers/mtd/spi-nor/spi-nor.c Boris Brezillon      2019-08-06  1879  
2dcbfe365b1303 drivers/mtd/spi-nor/spi-nor.c Jonathan Neuschäfer  2020-02-23  1880  		ret = spi_mem_exec_op(nor->spimem, &op);
b35b9a10362d20 drivers/mtd/spi-nor/spi-nor.c Boris Brezillon      2019-08-06  1881  	} else {
2dcbfe365b1303 drivers/mtd/spi-nor/spi-nor.c Jonathan Neuschäfer  2020-02-23  1882  		ret = nor->controller_ops->read_reg(nor, SPINOR_OP_RDID, id,
b35b9a10362d20 drivers/mtd/spi-nor/spi-nor.c Boris Brezillon      2019-08-06  1883  						    SPI_NOR_MAX_ID_LEN);
b35b9a10362d20 drivers/mtd/spi-nor/spi-nor.c Boris Brezillon      2019-08-06  1884  	}
2dcbfe365b1303 drivers/mtd/spi-nor/spi-nor.c Jonathan Neuschäfer  2020-02-23  1885  	if (ret) {
2dcbfe365b1303 drivers/mtd/spi-nor/spi-nor.c Jonathan Neuschäfer  2020-02-23  1886  		dev_dbg(nor->dev, "error %d reading JEDEC ID\n", ret);
2dcbfe365b1303 drivers/mtd/spi-nor/spi-nor.c Jonathan Neuschäfer  2020-02-23  1887  		return ERR_PTR(ret);
b199489d37b21c drivers/mtd/spi-nor/spi-nor.c Huang Shijie         2014-02-24  1888  	}
b199489d37b21c drivers/mtd/spi-nor/spi-nor.c Huang Shijie         2014-02-24  1889  
87a0aa695a2dba drivers/mtd/spi-nor/core.c    Sai Krishna Potthuri 2021-12-09  1890  	for (i = 0; i < SPI_NOR_MAX_ID_LEN; i++)
87a0aa695a2dba drivers/mtd/spi-nor/core.c    Sai Krishna Potthuri 2021-12-09 @1891  		nor->spimem->device_id[i] = id[i];
                                                                                                ^^^^^^^^^^^^^
Unchecked dereference

87a0aa695a2dba drivers/mtd/spi-nor/core.c    Sai Krishna Potthuri 2021-12-09  1892  
9ec4bbcb2044ea drivers/mtd/spi-nor/core.c    Boris Brezillon      2020-03-13  1893  	for (i = 0; i < ARRAY_SIZE(manufacturers); i++) {
9ec4bbcb2044ea drivers/mtd/spi-nor/core.c    Boris Brezillon      2020-03-13  1894  		info = spi_nor_search_part_by_id(manufacturers[i]->parts,
9ec4bbcb2044ea drivers/mtd/spi-nor/core.c    Boris Brezillon      2020-03-13  1895  						 manufacturers[i]->nparts,
9ec4bbcb2044ea drivers/mtd/spi-nor/core.c    Boris Brezillon      2020-03-13  1896  						 id);
9ec4bbcb2044ea drivers/mtd/spi-nor/core.c    Boris Brezillon      2020-03-13  1897  		if (info) {
9ec4bbcb2044ea drivers/mtd/spi-nor/core.c    Boris Brezillon      2020-03-13  1898  			nor->manufacturer = manufacturers[i];
9ec4bbcb2044ea drivers/mtd/spi-nor/core.c    Boris Brezillon      2020-03-13  1899  			return info;
b199489d37b21c drivers/mtd/spi-nor/spi-nor.c Huang Shijie         2014-02-24  1900  		}
9ec4bbcb2044ea drivers/mtd/spi-nor/core.c    Boris Brezillon      2020-03-13  1901  	}
9ec4bbcb2044ea drivers/mtd/spi-nor/core.c    Boris Brezillon      2020-03-13  1902  
3ddc8adbbc7683 drivers/mtd/spi-nor/spi-nor.c Geert Uytterhoeven   2019-03-12  1903  	dev_err(nor->dev, "unrecognized JEDEC id bytes: %*ph\n",
3ddc8adbbc7683 drivers/mtd/spi-nor/spi-nor.c Geert Uytterhoeven   2019-03-12  1904  		SPI_NOR_MAX_ID_LEN, id);
b199489d37b21c drivers/mtd/spi-nor/spi-nor.c Huang Shijie         2014-02-24  1905  	return ERR_PTR(-ENODEV);
b199489d37b21c drivers/mtd/spi-nor/spi-nor.c Huang Shijie         2014-02-24  1906  }

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




More information about the linux-arm-kernel mailing list