[PATCH] pinctrl: sh-pfc: fix a null pointer dereference of drive strength information

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Not all SoCs describes the drive strength registers. When reading the
sysfs pinconf-pins file on such a SoC this results in a null pointer
dereference. Protect against this dereference and allow reading of the
pinconf-pins by adding a check if the drive strength registers are
described or not.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@xxxxxxxxxxxx>
---
 drivers/pinctrl/sh-pfc/pinctrl.c | 3 +++
 1 file changed, 3 insertions(+)

---

Hi Geert,

This was found on the Eagle board and is based on the latest 
renesas/devel branch.

Regards,
Niklas

diff --git a/drivers/pinctrl/sh-pfc/pinctrl.c b/drivers/pinctrl/sh-pfc/pinctrl.c
index 654dc20e171b9363..ef837676d0312e8d 100644
--- a/drivers/pinctrl/sh-pfc/pinctrl.c
+++ b/drivers/pinctrl/sh-pfc/pinctrl.c
@@ -483,6 +483,9 @@ static u32 sh_pfc_pinconf_find_drive_strength_reg(struct sh_pfc *pfc,
 	const struct pinmux_drive_reg *reg;
 	unsigned int i;
 
+	if (!pfc->info->drive_regs)
+		return 0;
+
 	for (reg = pfc->info->drive_regs; reg->reg; ++reg) {
 		for (i = 0; i < ARRAY_SIZE(reg->fields); ++i) {
 			field = &reg->fields[i];
-- 
2.17.0

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux