diff mbox series

pmdomain: Add a null pointer check to the omap_prm_domain_init

Message ID 20240118054257.200814-1-chentao@kylinos.cn (mailing list archive)
State New, archived
Headers show
Series pmdomain: Add a null pointer check to the omap_prm_domain_init | expand

Commit Message

Kunwu Chan Jan. 18, 2024, 5:42 a.m. UTC
devm_kasprintf() returns a pointer to dynamically allocated memory
which can be NULL upon failure. Ensure the allocation was successful
by checking the pointer validity.

Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
---
 drivers/pmdomain/ti/omap_prm.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Ulf Hansson Jan. 22, 2024, 3:21 p.m. UTC | #1
On Thu, 18 Jan 2024 at 06:43, Kunwu Chan <chentao@kylinos.cn> wrote:
>
> devm_kasprintf() returns a pointer to dynamically allocated memory
> which can be NULL upon failure. Ensure the allocation was successful
> by checking the pointer validity.
>
> Signed-off-by: Kunwu Chan <chentao@kylinos.cn>

Applied for next, thanks!

Kind regards
Uffe


> ---
>  drivers/pmdomain/ti/omap_prm.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/pmdomain/ti/omap_prm.c b/drivers/pmdomain/ti/omap_prm.c
> index c2feae3a634c..b8ceb3c2b81c 100644
> --- a/drivers/pmdomain/ti/omap_prm.c
> +++ b/drivers/pmdomain/ti/omap_prm.c
> @@ -695,6 +695,8 @@ static int omap_prm_domain_init(struct device *dev, struct omap_prm *prm)
>         data = prm->data;
>         name = devm_kasprintf(dev, GFP_KERNEL, "prm_%s",
>                               data->name);
> +       if (!name)
> +               return -ENOMEM;
>
>         prmd->dev = dev;
>         prmd->prm = prm;
> --
> 2.39.2
>
diff mbox series

Patch

diff --git a/drivers/pmdomain/ti/omap_prm.c b/drivers/pmdomain/ti/omap_prm.c
index c2feae3a634c..b8ceb3c2b81c 100644
--- a/drivers/pmdomain/ti/omap_prm.c
+++ b/drivers/pmdomain/ti/omap_prm.c
@@ -695,6 +695,8 @@  static int omap_prm_domain_init(struct device *dev, struct omap_prm *prm)
 	data = prm->data;
 	name = devm_kasprintf(dev, GFP_KERNEL, "prm_%s",
 			      data->name);
+	if (!name)
+		return -ENOMEM;
 
 	prmd->dev = dev;
 	prmd->prm = prm;