* [PATCH] misc: tps6594-pfsm: Add NULL check in tps6594_pfsm_probe
@ 2025-04-10 10:52 Charles Han
2025-04-10 10:56 ` Arnd Bergmann
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Charles Han @ 2025-04-10 10:52 UTC (permalink / raw)
To: arnd, gregkh, jpanis; +Cc: linux-kernel, Charles Han
devm_kasprintf() can return a NULL pointer on failure,but this
returned value in tps6594_pfsm_probe() is not checked.
Add NULL check in tps6594_pfsm_probe(), to handle kernel NULL
pointer dereference error.
Fixes: a0df3ef087f8 ("misc: tps6594-pfsm: Add driver for TI TPS6594 PFSM")
Signed-off-by: Charles Han <hanchunchao@inspur.com>
---
drivers/misc/tps6594-pfsm.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/misc/tps6594-pfsm.c b/drivers/misc/tps6594-pfsm.c
index 0a24ce44cc37..05c4e081a8d2 100644
--- a/drivers/misc/tps6594-pfsm.c
+++ b/drivers/misc/tps6594-pfsm.c
@@ -281,6 +281,11 @@ static int tps6594_pfsm_probe(struct platform_device *pdev)
pfsm->miscdev.minor = MISC_DYNAMIC_MINOR;
pfsm->miscdev.name = devm_kasprintf(dev, GFP_KERNEL, "pfsm-%ld-0x%02x",
tps->chip_id, tps->reg);
+ if (!pfsm->miscdev.name) {
+ devm_kfree(dev, pfsm);
+ return -ENOMEM;
+ }
+
pfsm->miscdev.fops = &tps6594_pfsm_fops;
pfsm->miscdev.parent = dev->parent;
pfsm->chip_id = tps->chip_id;
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] misc: tps6594-pfsm: Add NULL check in tps6594_pfsm_probe
2025-04-10 10:52 [PATCH] misc: tps6594-pfsm: Add NULL check in tps6594_pfsm_probe Charles Han
@ 2025-04-10 10:56 ` Arnd Bergmann
2025-04-10 11:50 ` Greg KH
2025-04-10 11:50 ` Greg KH
2 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2025-04-10 10:56 UTC (permalink / raw)
To: Charles Han, Greg Kroah-Hartman, Julien Panis; +Cc: linux-kernel
On Thu, Apr 10, 2025, at 12:52, Charles Han wrote:
> + if (!pfsm->miscdev.name) {
> + devm_kfree(dev, pfsm);
> + return -ENOMEM;
> + }
Since this is the probe function, you don't need to call devm_kfree()
but just let devres take care of it.
Arnd
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] misc: tps6594-pfsm: Add NULL check in tps6594_pfsm_probe
2025-04-10 10:52 [PATCH] misc: tps6594-pfsm: Add NULL check in tps6594_pfsm_probe Charles Han
2025-04-10 10:56 ` Arnd Bergmann
@ 2025-04-10 11:50 ` Greg KH
2025-04-10 11:50 ` Greg KH
2 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2025-04-10 11:50 UTC (permalink / raw)
To: Charles Han; +Cc: arnd, jpanis, linux-kernel
On Thu, Apr 10, 2025 at 06:52:53PM +0800, Charles Han wrote:
> devm_kasprintf() can return a NULL pointer on failure,but this
> returned value in tps6594_pfsm_probe() is not checked.
> Add NULL check in tps6594_pfsm_probe(), to handle kernel NULL
> pointer dereference error.
>
> Fixes: a0df3ef087f8 ("misc: tps6594-pfsm: Add driver for TI TPS6594 PFSM")
> Signed-off-by: Charles Han <hanchunchao@inspur.com>
> ---
> drivers/misc/tps6594-pfsm.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/misc/tps6594-pfsm.c b/drivers/misc/tps6594-pfsm.c
> index 0a24ce44cc37..05c4e081a8d2 100644
> --- a/drivers/misc/tps6594-pfsm.c
> +++ b/drivers/misc/tps6594-pfsm.c
> @@ -281,6 +281,11 @@ static int tps6594_pfsm_probe(struct platform_device *pdev)
> pfsm->miscdev.minor = MISC_DYNAMIC_MINOR;
> pfsm->miscdev.name = devm_kasprintf(dev, GFP_KERNEL, "pfsm-%ld-0x%02x",
> tps->chip_id, tps->reg);
> + if (!pfsm->miscdev.name) {
> + devm_kfree(dev, pfsm);
> + return -ENOMEM;
> + }
How was this found and tested?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] misc: tps6594-pfsm: Add NULL check in tps6594_pfsm_probe
2025-04-10 10:52 [PATCH] misc: tps6594-pfsm: Add NULL check in tps6594_pfsm_probe Charles Han
2025-04-10 10:56 ` Arnd Bergmann
2025-04-10 11:50 ` Greg KH
@ 2025-04-10 11:50 ` Greg KH
2 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2025-04-10 11:50 UTC (permalink / raw)
To: Charles Han; +Cc: arnd, jpanis, linux-kernel
On Thu, Apr 10, 2025 at 06:52:53PM +0800, Charles Han wrote:
> devm_kasprintf() can return a NULL pointer on failure,but this
> returned value in tps6594_pfsm_probe() is not checked.
> Add NULL check in tps6594_pfsm_probe(), to handle kernel NULL
> pointer dereference error.
>
> Fixes: a0df3ef087f8 ("misc: tps6594-pfsm: Add driver for TI TPS6594 PFSM")
> Signed-off-by: Charles Han <hanchunchao@inspur.com>
> ---
> drivers/misc/tps6594-pfsm.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/misc/tps6594-pfsm.c b/drivers/misc/tps6594-pfsm.c
> index 0a24ce44cc37..05c4e081a8d2 100644
> --- a/drivers/misc/tps6594-pfsm.c
> +++ b/drivers/misc/tps6594-pfsm.c
> @@ -281,6 +281,11 @@ static int tps6594_pfsm_probe(struct platform_device *pdev)
> pfsm->miscdev.minor = MISC_DYNAMIC_MINOR;
> pfsm->miscdev.name = devm_kasprintf(dev, GFP_KERNEL, "pfsm-%ld-0x%02x",
> tps->chip_id, tps->reg);
> + if (!pfsm->miscdev.name) {
> + devm_kfree(dev, pfsm);
> + return -ENOMEM;
> + }
> +
> pfsm->miscdev.fops = &tps6594_pfsm_fops;
> pfsm->miscdev.parent = dev->parent;
> pfsm->chip_id = tps->chip_id;
> --
> 2.43.0
>
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him
a patch that has triggered this response. He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created. Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.
You are receiving this message because of the following common error(s)
as indicated below:
- You have marked a patch with a "Fixes:" tag for a commit that is in an
older released kernel, yet you do not have a cc: stable line in the
signed-off-by area at all, which means that the patch will not be
applied to any older kernel releases. To properly fix this, please
follow the documented rules in the
Documentation/process/stable-kernel-rules.rst file for how to resolve
this.
If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.
thanks,
greg k-h's patch email bot
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-04-10 11:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-10 10:52 [PATCH] misc: tps6594-pfsm: Add NULL check in tps6594_pfsm_probe Charles Han
2025-04-10 10:56 ` Arnd Bergmann
2025-04-10 11:50 ` Greg KH
2025-04-10 11:50 ` Greg KH
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®