[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220617051921.3801832-1-srinivas.neeli@xilinx.com>
Date: Fri, 17 Jun 2022 10:49:21 +0530
From: Srinivas Neeli <srinivas.neeli@...inx.com>
To: <linus.walleij@...aro.org>, <brgl@...ev.pl>,
<bgolaszewski@...libre.com>, <michal.simek@...inx.com>,
<neelisrinivas18@...il.com>, <shubhrajyoti.datta@...inx.com>,
<srinivas.neeli@....com>, <sgoud@...inx.com>
CC: <linux-gpio@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>, <git@...inx.com>,
Srinivas Neeli <srinivas.neeli@...inx.com>
Subject: [PATCH] gpio: gpio-xilinx: Check return value of of_property_read_u32
In five different instances the return value of "of_property_read_u32"
API was neither captured nor checked.
Fixed it by capturing the return value and then checking for any error.
Signed-off-by: Srinivas Neeli <srinivas.neeli@...inx.com>
Addresses-Coverity: "check_return"
---
drivers/gpio/gpio-xilinx.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c
index b6d3a57e27ed..268c7b0e481d 100644
--- a/drivers/gpio/gpio-xilinx.c
+++ b/drivers/gpio/gpio-xilinx.c
@@ -570,7 +570,8 @@ static int xgpio_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, chip);
/* First, check if the device is dual-channel */
- of_property_read_u32(np, "xlnx,is-dual", &is_dual);
+ if (of_property_read_u32(np, "xlnx,is-dual", &is_dual))
+ is_dual = 0;
/* Setup defaults */
memset32(width, 0, ARRAY_SIZE(width));
@@ -578,14 +579,18 @@ static int xgpio_probe(struct platform_device *pdev)
memset32(dir, 0xFFFFFFFF, ARRAY_SIZE(dir));
/* Update GPIO state shadow register with default value */
- of_property_read_u32(np, "xlnx,dout-default", &state[0]);
- of_property_read_u32(np, "xlnx,dout-default-2", &state[1]);
+ if (of_property_read_u32(np, "xlnx,dout-default", &state[0]))
+ state[0] = 0x0;
+ if (of_property_read_u32(np, "xlnx,dout-default-2", &state[1]))
+ state[1] = 0x0;
bitmap_from_arr32(chip->state, state, 64);
/* Update GPIO direction shadow register with default value */
- of_property_read_u32(np, "xlnx,tri-default", &dir[0]);
- of_property_read_u32(np, "xlnx,tri-default-2", &dir[1]);
+ if (of_property_read_u32(np, "xlnx,tri-default", &dir[0]))
+ dir[0] = 0xFFFFFFFF;
+ if (of_property_read_u32(np, "xlnx,tri-default-2", &dir[1]))
+ dir[1] = 0xFFFFFFFF;
bitmap_from_arr32(chip->dir, dir, 64);
--
2.25.1
Powered by blists - more mailing lists