summaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2020-03-11 10:06:44 +0100
committerLinus Walleij <linus.walleij@linaro.org>2020-03-27 11:30:24 +0100
commit7eb42f9855909cc10f5ba809c500ac0032fd60b8 (patch)
tree69d43a7e710d065ccac00031ff7fd78259326dc9 /drivers/pinctrl
parentpinctrl: freescale: drop the dependency on ARM64 for i.MX8M (diff)
downloadlinux-7eb42f9855909cc10f5ba809c500ac0032fd60b8.tar.xz
linux-7eb42f9855909cc10f5ba809c500ac0032fd60b8.zip
pinctrl: mediatek: Use scnprintf() for avoiding potential buffer overflow
Since snprintf() returns the would-be-output size instead of the actual output size, the succeeding calls may go beyond the given buffer limit. Fix it by replacing with scnprintf(). Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://lore.kernel.org/r/20200311090644.20287-1-tiwai@suse.de Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r--drivers/pinctrl/mediatek/pinctrl-paris.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c
index 3ee8086f5e55..3853ec3a2a8e 100644
--- a/drivers/pinctrl/mediatek/pinctrl-paris.c
+++ b/drivers/pinctrl/mediatek/pinctrl-paris.c
@@ -611,7 +611,7 @@ ssize_t mtk_pctrl_show_one_pin(struct mtk_pinctrl *hw,
} else if (pullen != MTK_DISABLE && pullen != MTK_ENABLE) {
pullen = 0;
}
- len += snprintf(buf + len, bufLen - len,
+ len += scnprintf(buf + len, bufLen - len,
"%03d: %1d%1d%1d%1d%02d%1d%1d%1d%1d",
gpio,
pinmux,
@@ -625,10 +625,10 @@ ssize_t mtk_pctrl_show_one_pin(struct mtk_pinctrl *hw,
pullup);
if (r1 != -1) {
- len += snprintf(buf + len, bufLen - len, " (%1d %1d)\n",
+ len += scnprintf(buf + len, bufLen - len, " (%1d %1d)\n",
r1, r0);
} else {
- len += snprintf(buf + len, bufLen - len, "\n");
+ len += scnprintf(buf + len, bufLen - len, "\n");
}
return len;