[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250624-k230-return-check-v1-1-6b4fc5ba0c41@whut.edu.cn>
Date: Tue, 24 Jun 2025 00:11:13 +0800
From: Ze Huang <huangze@...t.edu.cn>
To: Linus Walleij <linus.walleij@...aro.org>,
Ze Huang <18771902331@....com>
Cc: linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org,
Ze Huang <huangze@...t.edu.cn>, Yao Zi <ziyao@...root.org>
Subject: [PATCH 1/2] pinctrl: canaan: k230: add NULL check in DT parse
Add a NULL check for the return value of of_get_property() when
retrieving the "pinmux" property in the group parser. This avoids
a potential NULL pointer dereference if the property is missing
from the device tree node.
Also fix a typo ("sintenel") in the device ID match table comment,
correcting it to "sentinel".
Fixes: 545887eab6f6 ("pinctrl: canaan: Add support for k230 SoC")
Reported-by: Yao Zi <ziyao@...root.org>
Signed-off-by: Ze Huang <huangze@...t.edu.cn>
---
drivers/pinctrl/pinctrl-k230.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/pinctrl-k230.c b/drivers/pinctrl/pinctrl-k230.c
index a9b4627b46b01237801103df566b9391f8be21b8..4976308e62372c744738dd8372e73b2494e38e0b 100644
--- a/drivers/pinctrl/pinctrl-k230.c
+++ b/drivers/pinctrl/pinctrl-k230.c
@@ -477,6 +477,10 @@ static int k230_pinctrl_parse_groups(struct device_node *np,
grp->name = np->name;
list = of_get_property(np, "pinmux", &size);
+ if (!list) {
+ dev_err(dev, "failed to get pinmux property\n");
+ return -EINVAL;
+ }
size /= sizeof(*list);
grp->num_pins = size;
@@ -623,7 +627,7 @@ static int k230_pinctrl_probe(struct platform_device *pdev)
static const struct of_device_id k230_dt_ids[] = {
{ .compatible = "canaan,k230-pinctrl", },
- { /* sintenel */ }
+ { /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, k230_dt_ids);
--
2.50.0
Powered by blists - more mailing lists