Message ID | 20241207014727.3674388-1-zmw12306@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | spi: zynq-qspi: Add check for clk_enable() | expand |
On Fri, Dec 06, 2024 at 08:47:27PM -0500, Mingwei Zheng wrote: > - clk_enable(qspi->refclk); > - clk_enable(qspi->pclk); > + ret = clk_enable(qspi->refclk); > + if (ret) > + return ret; > + > + ret = clk_enable(qspi->pclk); > + if (ret) > + return ret; This second check leaks the first enable that was done.
diff --git a/drivers/spi/spi-zynq-qspi.c b/drivers/spi/spi-zynq-qspi.c index dee9c339a35e..ae8a955bb6f1 100644 --- a/drivers/spi/spi-zynq-qspi.c +++ b/drivers/spi/spi-zynq-qspi.c @@ -379,12 +379,18 @@ static int zynq_qspi_setup_op(struct spi_device *spi) { struct spi_controller *ctlr = spi->controller; struct zynq_qspi *qspi = spi_controller_get_devdata(ctlr); + int ret; if (ctlr->busy) return -EBUSY; - clk_enable(qspi->refclk); - clk_enable(qspi->pclk); + ret = clk_enable(qspi->refclk); + if (ret) + return ret; + + ret = clk_enable(qspi->pclk); + if (ret) + return ret; zynq_qspi_write(qspi, ZYNQ_QSPI_ENABLE_OFFSET, ZYNQ_QSPI_ENABLE_ENABLE_MASK);