Skip to content

Commit

Permalink
gpio: gpio-xilinx: Check return value of of_property_read_u32
Browse files Browse the repository at this point in the history
In two 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@xilinx.com>
Acked-by: Michal Simek <michal.simek@xilinx.com>
Addresses-Coverity: "check_return"
Link: https://lore.kernel.org/r/1605201148-4508-9-git-send-email-srinivas.neeli@xilinx.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Srinivas Neeli authored and Linus Walleij committed Nov 18, 2020
1 parent 0230a41 commit bea67ae
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/gpio/gpio-xilinx.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ static int xgpio_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, chip);

/* Update GPIO state shadow register with default value */
of_property_read_u32(np, "xlnx,dout-default", &chip->gpio_state[0]);
if (of_property_read_u32(np, "xlnx,dout-default", &chip->gpio_state[0]))
chip->gpio_state[0] = 0x0;

/* Update GPIO direction shadow register with default value */
if (of_property_read_u32(np, "xlnx,tri-default", &chip->gpio_dir[0]))
Expand All @@ -318,8 +319,9 @@ static int xgpio_probe(struct platform_device *pdev)

if (is_dual) {
/* Update GPIO state shadow register with default value */
of_property_read_u32(np, "xlnx,dout-default-2",
&chip->gpio_state[1]);
if (of_property_read_u32(np, "xlnx,dout-default-2",
&chip->gpio_state[1]))
chip->gpio_state[1] = 0x0;

/* Update GPIO direction shadow register with default value */
if (of_property_read_u32(np, "xlnx,tri-default-2",
Expand Down

0 comments on commit bea67ae

Please sign in to comment.