From: clingfei <clf700383@gmail.com>
To: drew@pdp7.com, guoren@kernel.org, wefu@redhat.com,
linus.walleij@linaro.org
Cc: linux-riscv@lists.infradead.org, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org, clf700383@gmail.com
Subject: [PATCH] pinctrl: fix Null pointer dereference
Date: Thu, 3 Oct 2024 10:33:07 +0800 [thread overview]
Message-ID: <20241003023307.2138695-1-clf700383@gmail.com> (raw)
pinmux_generic_get_function may returns NULL, and its retval is
dereferenced without check, which will cause a null pointer dereference.
Signed-off-by: clingfei <clf700383@gmail.com>
---
drivers/pinctrl/pinctrl-th1520.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/pinctrl/pinctrl-th1520.c b/drivers/pinctrl/pinctrl-th1520.c
index 1bb78b212fd5..9331f4462480 100644
--- a/drivers/pinctrl/pinctrl-th1520.c
+++ b/drivers/pinctrl/pinctrl-th1520.c
@@ -798,6 +798,8 @@ static int th1520_pinmux_set_mux(struct pinctrl_dev *pctldev,
struct th1520_pinctrl *thp = pinctrl_dev_get_drvdata(pctldev);
const struct function_desc *func = pinmux_generic_get_function(pctldev, fsel);
+ if (!func)
+ return -EINVAL;
return th1520_pinmux_set(thp, thp->desc.pins[gsel].number,
(uintptr_t)thp->desc.pins[gsel].drv_data & TH1520_PAD_MUXDATA,
(uintptr_t)func->data);
--
2.34.1
next reply other threads:[~2024-10-03 2:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-03 2:33 clingfei [this message]
2024-10-03 2:56 ` [PATCH] pinctrl: fix Null pointer dereference Drew Fustini
2024-10-03 14:08 ` Linus Walleij
-- strict thread matches above, loose matches on Subject: below --
2024-10-03 1:52 xi xi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241003023307.2138695-1-clf700383@gmail.com \
--to=clf700383@gmail.com \
--cc=drew@pdp7.com \
--cc=guoren@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=wefu@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).