[PATCH] pinctrl: renesas:fix possible null pointer dereference struct pinmux_range *
From: alex_luca
Date: Sun Feb 07 2021 - 12:48:19 EST
From: Zhang Kun <zhangkun@xxxxxxxxxx>
The parameters of sh_pfc_enum_in_range() pinmux_range *r should be checked
first for possible null ponter, especially when PINMUX_TYPE_FUNCTION as the
pinmux_type was passed by sh_pfc_config_mux().
Signed-off-by: Zhang Kun <zhangkun@xxxxxxxxxx>
---
drivers/pinctrl/renesas/core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/pinctrl/renesas/core.c b/drivers/pinctrl/renesas/core.c
index 2cc457279345..40bbc8366668 100644
--- a/drivers/pinctrl/renesas/core.c
+++ b/drivers/pinctrl/renesas/core.c
@@ -128,6 +128,9 @@ int sh_pfc_get_pin_index(struct sh_pfc *pfc, unsigned int pin)
static int sh_pfc_enum_in_range(u16 enum_id, const struct pinmux_range *r)
{
+ if (!r)
+ return 0;
+
if (enum_id < r->begin)
return 0;
--
2.17.1