[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0d45776f-264f-427c-964e-65be8955aafe@web.de>
Date: Mon, 30 Sep 2024 17:25:05 +0200
From: Markus Elfring <Markus.Elfring@....de>
To: Zichen Xie <zichenxie0106@...il.com>, kernel-janitors@...r.kernel.org,
Chanwoo Choi <cw00.choi@...sung.com>, MyungJoo Ham
<myungjoo.ham@...sung.com>, Stanley Chang <stanley_chang@...ltek.com>
Cc: LKML <linux-kernel@...r.kernel.org>, Zijie Zhao <zzjas98@...il.com>,
Chenyuan Yang <chenyuan0y@...il.com>
Subject: Re: [PATCH] Fix possible NULL Pointer Dereference in
'extcon_rtk_type_c_probe'
> 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@...il.com>
> Reported-by: Zichen Xie <zichenxie0106@...il.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
Powered by blists - more mailing lists