linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [bug report] mtd: spi-nor: Introduce 'struct spi_nor_controller_ops'
@ 2019-10-25  9:03 Dan Carpenter
  2019-10-25 11:24 ` Tudor.Ambarus
  0 siblings, 1 reply; 12+ messages in thread
From: Dan Carpenter @ 2019-10-25  9:03 UTC (permalink / raw)
  To: tudor.ambarus; +Cc: linux-mtd

Hello Tudor Ambarus,

This is a semi-automatic email about new static checker warnings.

The patch 453977875364: "mtd: spi-nor: Introduce 'struct
spi_nor_controller_ops'" from Sep 24, 2019, leads to the following
Smatch complaint:

    drivers/mtd/spi-nor/spi-nor.c:967 spi_nor_erase_sector()
    error: we previously assumed 'nor->controller_ops' could be null (see line 945)

drivers/mtd/spi-nor/spi-nor.c
   944	
   945		if (nor->controller_ops && nor->controller_ops->erase)
                    ^^^^^^^^^^^^^^^^^^^
Can this really be NULL?  Probably this check can be removed...

   946			return nor->controller_ops->erase(nor, addr);
   947	
   948		if (nor->spimem) {
   949			struct spi_mem_op op =
   950				SPI_MEM_OP(SPI_MEM_OP_CMD(nor->erase_opcode, 1),
   951					   SPI_MEM_OP_ADDR(nor->addr_width, addr, 1),
   952					   SPI_MEM_OP_NO_DUMMY,
   953					   SPI_MEM_OP_NO_DATA);
   954	
   955			return spi_mem_exec_op(nor->spimem, &op);
   956		}
   957	
   958		/*
   959		 * Default implementation, if driver doesn't have a specialized HW
   960		 * control
   961		 */
   962		for (i = nor->addr_width - 1; i >= 0; i--) {
   963			nor->bouncebuf[i] = addr & 0xff;
   964			addr >>= 8;
   965		}
   966	
   967		return nor->controller_ops->write_reg(nor, nor->erase_opcode,
                       ^^^^^^^^^^^^^^^^^^^^^
The patch adds a new unchecked dereference.

   968						      nor->bouncebuf, nor->addr_width);
   969	}

regards,
dan carpenter

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-11-11 19:28 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-25  9:03 [bug report] mtd: spi-nor: Introduce 'struct spi_nor_controller_ops' Dan Carpenter
2019-10-25 11:24 ` Tudor.Ambarus
2019-10-25 12:32   ` [PATCH] mtd: spi-nor: Move condition to avoid a NULL check Tudor.Ambarus
2019-10-25 12:37     ` Dan Carpenter
2019-10-25 14:28     ` [PATCH v2 1/2] mtd: spi-nor: Make sure nor->spimem and nor->controller_ops are mutual exclusive Tudor.Ambarus
2019-10-25 14:28       ` [PATCH v2 2/2] mtd: spi-nor: Move condition to avoid a NULL check Tudor.Ambarus
2019-11-11  9:08         ` Boris Brezillon
2019-11-11 19:28         ` Tudor.Ambarus
2019-11-11  9:02       ` [PATCH v2 1/2] mtd: spi-nor: Make sure nor->spimem and nor->controller_ops are mutual exclusive Boris Brezillon
2019-11-11  9:44         ` [PATCH] mtd: spi-nor: Make sure nor->spimem and nor->controller_ops are mutually exclusive Tudor.Ambarus
2019-11-11 15:59           ` Boris Brezillon
2019-11-11 19:26           ` Tudor.Ambarus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).