diff mbox series

pinctrl: sunplus: Delete an unnecessary check before kfree() in sppctl_dt_node_to_map()

Message ID 9ace5c4c-5e17-4207-5a02-6a47ba0aee22@web.de (mailing list archive)
State New, archived
Headers show
Series pinctrl: sunplus: Delete an unnecessary check before kfree() in sppctl_dt_node_to_map() | expand

Commit Message

Markus Elfring June 6, 2023, 1:26 p.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Jun 2023 15:00:18 +0200

It can be known that the function “kfree” performs a null pointer check
for its input parameter.
It is therefore not needed to repeat such a check before its call.

Thus remove a redundant pointer check.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/pinctrl/sunplus/sppctl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--
2.40.1

Comments

Andy Shevchenko June 6, 2023, 2:39 p.m. UTC | #1
On Tue, Jun 6, 2023 at 4:26 PM Markus Elfring <Markus.Elfring@web.de> wrote:
>
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 6 Jun 2023 15:00:18 +0200

You need to utilize what MAINTAINERS file has.

> It can be known that the function “kfree” performs a null pointer check
> for its input parameter.
> It is therefore not needed to repeat such a check before its call.
>
> Thus remove a redundant pointer check.

Seems reasonable to me.
FWIW,
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/pinctrl/sunplus/sppctl.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/pinctrl/sunplus/sppctl.c b/drivers/pinctrl/sunplus/sppctl.c
> index e91ce5b5d559..150996949ede 100644
> --- a/drivers/pinctrl/sunplus/sppctl.c
> +++ b/drivers/pinctrl/sunplus/sppctl.c
> @@ -971,8 +971,7 @@ static int sppctl_dt_node_to_map(struct pinctrl_dev *pctldev, struct device_node
>
>  sppctl_map_err:
>         for (i = 0; i < (*num_maps); i++)
> -               if (((*map)[i].type == PIN_MAP_TYPE_CONFIGS_PIN) &&
> -                   (*map)[i].data.configs.configs)
> +               if ((*map)[i].type == PIN_MAP_TYPE_CONFIGS_PIN)
>                         kfree((*map)[i].data.configs.configs);
>         kfree(*map);
>         of_node_put(parent);
> --
> 2.40.1
>
Linus Walleij June 9, 2023, 7:32 a.m. UTC | #2
On Tue, Jun 6, 2023 at 3:26 PM Markus Elfring <Markus.Elfring@web.de> wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 6 Jun 2023 15:00:18 +0200
>
> It can be known that the function “kfree” performs a null pointer check
> for its input parameter.
> It is therefore not needed to repeat such a check before its call.
>
> Thus remove a redundant pointer check.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Lu Hongfei sent a patch changing the code around this location
so I rebased it manually and applied, check the result, thanks!

Yours,
Linus Walleij
Markus Elfring June 13, 2023, 10:42 a.m. UTC | #3
> Lu Hongfei sent a patch changing the code around this location

To which contribution do you refer here?


> so I rebased it manually and applied, check the result, thanks!

I noticed another commit with the questionable subject
“pinctrl:sunplus: Add check for kmalloc”.
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/drivers/pinctrl/sunplus/sppctl.c?h=next-20230613&id=73f8ce7f961afcb3be49352efeb7c26cc1c00cc4

I find such a commit message inappropriate for the applied
source code adjustment.

Regards,
Markus
diff mbox series

Patch

diff --git a/drivers/pinctrl/sunplus/sppctl.c b/drivers/pinctrl/sunplus/sppctl.c
index e91ce5b5d559..150996949ede 100644
--- a/drivers/pinctrl/sunplus/sppctl.c
+++ b/drivers/pinctrl/sunplus/sppctl.c
@@ -971,8 +971,7 @@  static int sppctl_dt_node_to_map(struct pinctrl_dev *pctldev, struct device_node

 sppctl_map_err:
 	for (i = 0; i < (*num_maps); i++)
-		if (((*map)[i].type == PIN_MAP_TYPE_CONFIGS_PIN) &&
-		    (*map)[i].data.configs.configs)
+		if ((*map)[i].type == PIN_MAP_TYPE_CONFIGS_PIN)
 			kfree((*map)[i].data.configs.configs);
 	kfree(*map);
 	of_node_put(parent);