[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190928002852.28329-1-yzhai003@ucr.edu>
Date: Fri, 27 Sep 2019 17:28:51 -0700
From: Yizhuo <yzhai003@....edu>
To: unlisted-recipients:; (no To-header on input)
Cc: csong@...ucr.edu, zhiyunq@...ucr.edu, Yizhuo <yzhai003@....edu>,
Jonathan Cameron <jic23@...nel.org>,
Hartmut Knaack <knaack.h@....de>,
Lars-Peter Clausen <lars@...afoo.de>,
Peter Meerwald-Stadler <pmeerw@...erw.net>,
Shawn Guo <shawnguo@...nel.org>,
Sascha Hauer <s.hauer@...gutronix.de>,
Pengutronix Kernel Team <kernel@...gutronix.de>,
Fabio Estevam <festevam@...il.com>,
NXP Linux Team <linux-imx@....com>,
Kate Stewart <kstewart@...uxfoundation.org>,
Allison Randal <allison@...utok.net>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Enrico Weigelt <info@...ux.net>,
Thomas Gleixner <tglx@...utronix.de>,
linux-iio@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] iio: adc: imx25-gcq: Variable could be uninitialized if regmap_read() fails
In function mx25_gcq_irq(), local variable "stats" could
be uninitialized if function regmap_read() returns -EINVAL.
However, this value is used in if statement, which is
potentially unsafe. The same case applied to the variable
"data" in function mx25_gcq_get_raw_value() in the same file.
Signed-off-by: Yizhuo <yzhai003@....edu>
---
drivers/iio/adc/fsl-imx25-gcq.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/adc/fsl-imx25-gcq.c b/drivers/iio/adc/fsl-imx25-gcq.c
index df19ecae52f7..dbf3e8e85aba 100644
--- a/drivers/iio/adc/fsl-imx25-gcq.c
+++ b/drivers/iio/adc/fsl-imx25-gcq.c
@@ -74,7 +74,10 @@ static irqreturn_t mx25_gcq_irq(int irq, void *data)
struct mx25_gcq_priv *priv = data;
u32 stats;
- regmap_read(priv->regs, MX25_ADCQ_SR, &stats);
+ int ret = regmap_read(priv->regs, MX25_ADCQ_SR, &stats);
+
+ if (ret)
+ return ret;
if (stats & MX25_ADCQ_SR_EOQ) {
regmap_update_bits(priv->regs, MX25_ADCQ_MR,
@@ -121,7 +124,10 @@ static int mx25_gcq_get_raw_value(struct device *dev,
return -ETIMEDOUT;
}
- regmap_read(priv->regs, MX25_ADCQ_FIFO, &data);
+ int ret = regmap_read(priv->regs, MX25_ADCQ_FIFO, &data);
+
+ if (ret)
+ return ret;
*val = MX25_ADCQ_FIFO_DATA(data);
--
2.17.1
Powered by blists - more mailing lists