From: Gax-c <zichenxie0106@gmail.com>
To: myungjoo.ham@samsung.com, cw00.choi@samsung.com,
stanley_chang@realtek.com
Cc: linux-kernel@vger.kernel.org, Gax-c <zichenxie0106@gmail.com>,
Zijie Zhao <zzjas98@gmail.com>,
Chenyuan Yang <chenyuan0y@gmail.com>
Subject: [PATCH] Fix possible NULL Pointer Dereference in 'extcon_rtk_type_c_probe'
Date: Sun, 29 Sep 2024 17:38:13 -0500 [thread overview]
Message-ID: <20240929223813.21164-1-zichenxie0106@gmail.com> (raw)
A 'devm_kzalloc' in 'extcon_rtk_type_c_probe' could possibly return null pointer.
Add a null check for the returned pointer.
Fixes: 8a590d7371f0 ("extcon: add Realtek DHC RTD SoC Type-C driver")
Signed-off-by: Zichen Xie <zichenxie0106@gmail.com>
Reported-by: Zichen Xie <zichenxie0106@gmail.com>
Reported-by: Zijie Zhao <zzjas98@gmail.com>
Reported-by: Chenyuan Yang <chenyuan0y@gmail.com>
---
drivers/extcon/extcon-rtk-type-c.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/extcon/extcon-rtk-type-c.c b/drivers/extcon/extcon-rtk-type-c.c
index a592bab77538..9a0824fc7cbe 100644
--- a/drivers/extcon/extcon-rtk-type-c.c
+++ b/drivers/extcon/extcon-rtk-type-c.c
@@ -1371,6 +1371,12 @@ static int extcon_rtk_type_c_probe(struct platform_device *pdev)
type_c->type_c_cfg = devm_kzalloc(dev, sizeof(*type_c_cfg), GFP_KERNEL);
+ if (!type_c->type_c_cfg) {
+ dev_err(dev, "Failed to allocate memory for type_c_cfg!\n");
+ ret = -ENOMEM;
+ goto err;
+ }
+
memcpy(type_c->type_c_cfg, type_c_cfg, sizeof(*type_c_cfg));
if (setup_type_c_parameter(type_c)) {
--
2.25.1
next reply other threads:[~2024-09-29 22:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-29 22:38 Gax-c [this message]
2024-09-30 15:25 ` Markus Elfring
2024-10-01 19:48 ` Krzysztof Kozlowski
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=20240929223813.21164-1-zichenxie0106@gmail.com \
--to=zichenxie0106@gmail.com \
--cc=chenyuan0y@gmail.com \
--cc=cw00.choi@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=myungjoo.ham@samsung.com \
--cc=stanley_chang@realtek.com \
--cc=zzjas98@gmail.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
all inboxes | Powered by JetHome®