From: Markus Elfring <Markus.Elfring@web.de>
To: Zichen Xie <zichenxie0106@gmail.com>,
kernel-janitors@vger.kernel.org,
Chanwoo Choi <cw00.choi@samsung.com>,
MyungJoo Ham <myungjoo.ham@samsung.com>,
Stanley Chang <stanley_chang@realtek.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
Zijie Zhao <zzjas98@gmail.com>,
Chenyuan Yang <chenyuan0y@gmail.com>
Subject: Re: [PATCH] Fix possible NULL Pointer Dereference in 'extcon_rtk_type_c_probe'
Date: Mon, 30 Sep 2024 17:25:05 +0200 [thread overview]
Message-ID: <0d45776f-264f-427c-964e-65be8955aafe@web.de> (raw)
In-Reply-To: <20240929223813.21164-1-zichenxie0106@gmail.com>
> A 'devm_kzalloc' in 'extcon_rtk_type_c_probe' could possibly return null pointer.
> Add a null check for the returned pointer.
How do you think about a wording variant like the following?
A devm_kzalloc() call can fail in this function implementation.
Thus add a null pointer check and corresponding exception handling
for the data structure member “type_c_cfg”.
…
> Signed-off-by: Zichen Xie <zichenxie0106@gmail.com>
> Reported-by: Zichen Xie <zichenxie0106@gmail.com>
…
How good does such a tag combination fit together for the same person?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.11#n525
Can a subject like “[PATCH] extcon: realtek: Prevent null pointer dereference in extcon_rtk_type_c_probe()”
be more appropriate?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.11#n613
…
> +++ 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));
…
I suggest to omit an extra error message here.
By the way:
Would you become interested to add a jump target for the statement “ret = -EINVAL;”
(in two other if branches)?
Regards,
Markus
next prev parent reply other threads:[~2024-09-30 15:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-29 22:38 Gax-c
2024-09-30 15:25 ` Markus Elfring [this message]
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=0d45776f-264f-427c-964e-65be8955aafe@web.de \
--to=markus.elfring@web.de \
--cc=chenyuan0y@gmail.com \
--cc=cw00.choi@samsung.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=myungjoo.ham@samsung.com \
--cc=stanley_chang@realtek.com \
--cc=zichenxie0106@gmail.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®