[PATCH] gpu: ipu-v3: Variable "val" in function ipu_prg_get_pre() could be uninitialized

Yizhuo yzhai003 at ucr.edu
Mon Jan 28 22:55:24 UTC 2019


In function ipu_prg_get_pre(), local variable "val" could
be uninitialized if function regmap_read() returns -EINVAL.
However, this value is used in if statement. This is
potentially unsafe.

Signed-off-by: Yizhuo <yzhai003 at ucr.edu>
---
 drivers/gpu/ipu-v3/ipu-prg.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/ipu-v3/ipu-prg.c b/drivers/gpu/ipu-v3/ipu-prg.c
index 0013ca9f72c8..df12777d9be7 100644
--- a/drivers/gpu/ipu-v3/ipu-prg.c
+++ b/drivers/gpu/ipu-v3/ipu-prg.c
@@ -210,6 +210,7 @@ static int ipu_prg_get_pre(struct ipu_prg *prg, int prg_chan)
 		if (!ret) {
 			u32 val, mux;
 			int shift;
+			int err;
 
 			prg->chan[prg_chan].used_pre = i;
 
@@ -221,7 +222,12 @@ static int ipu_prg_get_pre(struct ipu_prg *prg, int prg_chan)
 
 			/* check other mux, must not point to same channel */
 			shift = (i == 1) ? 14 : 12;
-			regmap_read(prg->iomuxc_gpr, IOMUXC_GPR5, &val);
+			err = regmap_read(prg->iomuxc_gpr, IOMUXC_GPR5, &val);
+			if (err < 0) {
+				dev_err(prg->dev, "read IOMUXC_GPRS failed\n");
+				return err;
+			}
+
 			if (((val >> shift) & 0x3) == mux) {
 				regmap_update_bits(prg->iomuxc_gpr, IOMUXC_GPR5,
 						   0x3 << shift,
-- 
2.17.1



More information about the dri-devel mailing list