Commit 9063777c authored by Xiaolei Wang's avatar Xiaolei Wang Committed by Linus Walleij
Browse files

pinctrl: freescale: Fix a memory out of bounds when num_configs is 1



The config passed in by pad wakeup is 1, when num_configs is 1,
Configuration [1] should not be fetched, which will be detected
by KASAN as a memory out of bounds condition. Modify to get
configs[1] when num_configs is 2.

Fixes: f60c9eac ("gpio: mxc: enable pad wakeup on i.MX8x platforms")
Signed-off-by: default avatarXiaolei Wang <xiaolei.wang@windriver.com>
Reviewed-by: default avatarPeng Fan <peng.fan@nxp.com>
Link: https://lore.kernel.org/r/20230504233736.3766296-1-xiaolei.wang@windriver.com


Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 4e739807
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ int imx_pinconf_set_scu(struct pinctrl_dev *pctldev, unsigned pin_id,
	struct imx_sc_msg_req_pad_set msg;
	struct imx_sc_rpc_msg *hdr = &msg.hdr;
	unsigned int mux = configs[0];
	unsigned int conf = configs[1];
	unsigned int conf;
	unsigned int val;
	int ret;

@@ -115,6 +115,7 @@ int imx_pinconf_set_scu(struct pinctrl_dev *pctldev, unsigned pin_id,
	 * Set mux and conf together in one IPC call
	 */
	WARN_ON(num_configs != 2);
	conf = configs[1];

	val = conf | BM_PAD_CTL_IFMUX_ENABLE | BM_PAD_CTL_GP_ENABLE;
	val |= mux << BP_PAD_CTL_IFMUX;