mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] extcon: realtek: fix NULL deref check in extcon_rtk_type_c_probe
@ 2024-10-25  9:46 Charles Han
  2024-11-18 12:00 ` Markus Elfring
  2024-12-08 12:45 ` Chanwoo Choi
  0 siblings, 2 replies; 3+ messages in thread
From: Charles Han @ 2024-10-25  9:46 UTC (permalink / raw)
  To: stanley_chang, myungjoo.ham, cw00.choi; +Cc: linux-kernel, Charles Han

In extcon_rtk_type_c_probe() devm_kzalloc() may return NULL but this
returned value is not checked.

Fixes: 8a590d7371f0 ("extcon: add Realtek DHC RTD SoC Type-C driver")
Signed-off-by: Charles Han <hanchunchao@inspur.com>
---
 drivers/extcon/extcon-rtk-type-c.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/extcon/extcon-rtk-type-c.c b/drivers/extcon/extcon-rtk-type-c.c
index 19a01e663733..2820c7e82481 100644
--- a/drivers/extcon/extcon-rtk-type-c.c
+++ b/drivers/extcon/extcon-rtk-type-c.c
@@ -1369,6 +1369,8 @@ 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)
+		return -ENOMEM;
 
 	memcpy(type_c->type_c_cfg, type_c_cfg, sizeof(*type_c_cfg));
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] extcon: realtek: fix NULL deref check in extcon_rtk_type_c_probe
  2024-10-25  9:46 [PATCH] extcon: realtek: fix NULL deref check in extcon_rtk_type_c_probe Charles Han
@ 2024-11-18 12:00 ` Markus Elfring
  2024-12-08 12:45 ` Chanwoo Choi
  1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2024-11-18 12:00 UTC (permalink / raw)
  To: Charles Han, Chanwoo Choi, MyungJoo Ham, Stanley Chang; +Cc: LKML

> In extcon_rtk_type_c_probe() devm_kzalloc() may return NULL but this
> returned value is not checked.

Another wording suggestion:
A devm_kzalloc() call can return a null pointer on failure.
But such a return value was not checked in this function implementation.
Thus add a corresponding check so that a null pointer dereference
will be avoided.


Would a summary phrase like “Prevent null pointer dereference in extcon_rtk_type_c_probe()”
be a bit nicer?

Regards,
Markus

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] extcon: realtek: fix NULL deref check in extcon_rtk_type_c_probe
  2024-10-25  9:46 [PATCH] extcon: realtek: fix NULL deref check in extcon_rtk_type_c_probe Charles Han
  2024-11-18 12:00 ` Markus Elfring
@ 2024-12-08 12:45 ` Chanwoo Choi
  1 sibling, 0 replies; 3+ messages in thread
From: Chanwoo Choi @ 2024-12-08 12:45 UTC (permalink / raw)
  To: Charles Han; +Cc: stanley_chang, myungjoo.ham, cw00.choi, linux-kernel

Hi,

Applied it. Thanks.

On Fri, Oct 25, 2024 at 6:55 PM Charles Han <hanchunchao@inspur.com> wrote:
>
> In extcon_rtk_type_c_probe() devm_kzalloc() may return NULL but this
> returned value is not checked.
>
> Fixes: 8a590d7371f0 ("extcon: add Realtek DHC RTD SoC Type-C driver")
> Signed-off-by: Charles Han <hanchunchao@inspur.com>
> ---
>  drivers/extcon/extcon-rtk-type-c.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/extcon/extcon-rtk-type-c.c b/drivers/extcon/extcon-rtk-type-c.c
> index 19a01e663733..2820c7e82481 100644
> --- a/drivers/extcon/extcon-rtk-type-c.c
> +++ b/drivers/extcon/extcon-rtk-type-c.c
> @@ -1369,6 +1369,8 @@ 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)
> +               return -ENOMEM;
>
>         memcpy(type_c->type_c_cfg, type_c_cfg, sizeof(*type_c_cfg));
>
> --
> 2.31.1
>
>


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-12-08 12:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-25  9:46 [PATCH] extcon: realtek: fix NULL deref check in extcon_rtk_type_c_probe Charles Han
2024-11-18 12:00 ` Markus Elfring
2024-12-08 12:45 ` Chanwoo Choi

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®