[PATCH v3 02/10] pinctrl: scmi: refuse an inexact drive strength in milliamperes
From: Clément Le Goffic
Date: Mon Nov 23 2026 - 10:21:44 EST
A get of PIN_CONFIG_DRIVE_STRENGTH truncated a value that is not a whole
milliampere, and a set did not check the conversion to microamperes for
an overflow.
Return -EINVAL in both cases instead of truncating or wrapping.
PIN_CONFIG_DRIVE_STRENGTH_UA still reads the exact value.
Fixes: cc2f90768e97 ("pinctrl: scmi: send the drive strength in microamperes")
Reported-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
Closes: https://lore.kernel.org/all/CAMuHMdWwp4RtKnBpFNJPHdigzrQ-wf3yt-pBZGG9QKs9tcd_Ow@xxxxxxxxxxxxxx/
Signed-off-by: Clément Le Goffic <clegoffic@xxxxxxxxxxxx>
---
drivers/pinctrl/pinctrl-scmi.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c
index b088a24e4ec0..23287c3add35 100644
--- a/drivers/pinctrl/pinctrl-scmi.c
+++ b/drivers/pinctrl/pinctrl-scmi.c
@@ -11,6 +11,7 @@
#include <linux/errno.h>
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/overflow.h>
#include <linux/scmi_protocol.h>
#include <linux/slab.h>
#include <linux/types.h>
@@ -179,8 +180,11 @@ static int pinctrl_scmi_map_pinconf_arg_get(enum pin_config_param param, u32 *va
if (pinctrl_scmi_pinconf_inactive_flag(param, *value))
return -EINVAL;
- if (param == PIN_CONFIG_DRIVE_STRENGTH)
+ if (param == PIN_CONFIG_DRIVE_STRENGTH) {
+ if (*value % MILLI)
+ return -EINVAL;
*value /= MILLI;
+ }
return 0;
}
@@ -223,8 +227,10 @@ static int pinctrl_scmi_map_pinconf_type_set(enum pin_config_param param,
if (pinctrl_scmi_pinconf_arg_ignored(param))
*arg = 1;
- if (param == PIN_CONFIG_DRIVE_STRENGTH)
- *arg *= MILLI;
+ if (param == PIN_CONFIG_DRIVE_STRENGTH) {
+ if (check_mul_overflow(*arg, MILLI, arg))
+ return -EINVAL;
+ }
return pinctrl_scmi_map_pinconf_type(param, type);
}
--
2.56.1