diff mbox series

[1/1] Preventive patch in the pin control subsystem to handle NULL check.

Message ID 1535359139-6264-1-git-send-email-srikanth.h@samsung.com
State New
Headers show
Series [1/1] Preventive patch in the pin control subsystem to handle NULL check. | expand

Commit Message

Srikanth Korangala Hari Aug. 27, 2018, 8:38 a.m. UTC
If the pin descriptor requested for the physical pin fails then the
descriptor is dereferenced without checking for its validity which
may lead to crash, hence added preventive code to check for NULL
and accordingly dereference.

Signed-off-by: Srikanth K H <srikanth.h@samsung.com>
---
 drivers/pinctrl/pinconf.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Srikanth Korangala Hari Aug. 29, 2018, 10:25 a.m. UTC | #1
> If the pin descriptor requested for the physical pin fails then the
> descriptor is dereferenced without checking for its validity which
> may lead to crash, hence added preventive code to check for NULL
> and accordingly dereference.
 
> Signed-off-by: Srikanth K H <srikanth.h@samsung.com>
> ---
> drivers/pinctrl/pinconf.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
 
> diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c
> index d3fe143..576d08d 100644
> --- a/drivers/pinctrl/pinconf.c
> +++ b/drivers/pinctrl/pinconf.c
> @@ -269,8 +269,9 @@ void pinconf_show_setting(struct seq_file *s,
>         case PIN_MAP_TYPE_CONFIGS_PIN:
>                 desc = pin_desc_get(setting->pctldev,
>                                     setting->data.configs.group_or_pin);
> -                seq_printf(s, "pin %s (%d)", desc->name,
> -                           setting->data.configs.group_or_pin);
> +                if (desc)
> +                        seq_printf(s, "pin %s (%d)", desc->name,
> +                                   setting->data.configs.group_or_pin);
>                 break;
>         case PIN_MAP_TYPE_CONFIGS_GROUP:
>                 seq_printf(s, "group %s (%d)",

Dear Maintainer's,

Please confirm me whether the above patch is considered for merging onto mainline ?

Thanks,
Srikanth
Linus Walleij Aug. 30, 2018, 9:03 a.m. UTC | #2
Hi Srikanth, thanks for your patch!

On Mon, Aug 27, 2018 at 10:39 AM Srikanth K H <srikanth.h@samsung.com> wrote:

 @@ -269,8 +269,9 @@ void pinconf_show_setting(struct seq_file *s,

>                 desc = pin_desc_get(setting->pctldev,
>                                     setting->data.configs.group_or_pin);
> -               seq_printf(s, "pin %s (%d)", desc->name,
> -                          setting->data.configs.group_or_pin);
> +               if (desc)
> +                       seq_printf(s, "pin %s (%d)", desc->name,
> +                                  setting->data.configs.group_or_pin);

Under what circumstances do you expect this to happen?
Did you provoke it with a real usecase during development?

We do not sprinkle NULL or error handling over code that
will not derail, and since this is in debugfs we are even more
lax.

If it annoys users (which would then be developers using
debugfs during development), then we need to look into it.

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c
index d3fe143..576d08d 100644
--- a/drivers/pinctrl/pinconf.c
+++ b/drivers/pinctrl/pinconf.c
@@ -269,8 +269,9 @@  void pinconf_show_setting(struct seq_file *s,
 	case PIN_MAP_TYPE_CONFIGS_PIN:
 		desc = pin_desc_get(setting->pctldev,
 				    setting->data.configs.group_or_pin);
-		seq_printf(s, "pin %s (%d)", desc->name,
-			   setting->data.configs.group_or_pin);
+		if (desc)
+			seq_printf(s, "pin %s (%d)", desc->name,
+				   setting->data.configs.group_or_pin);
 		break;
 	case PIN_MAP_TYPE_CONFIGS_GROUP:
 		seq_printf(s, "group %s (%d)",