aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/ibmpowernv.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2020-03-11 08:39:44 +0100
committerGuenter Roeck <linux@roeck-us.net>2020-03-11 08:09:31 -0700
commit6a096871b2bedd524ce706aa687de4f7145f535c (patch)
treefcaa27f85d98e8a628c00abc9c247d6de5b20df5 /drivers/hwmon/ibmpowernv.c
parenthwmon: (adt7475) Add support for inverting pwm output (diff)
downloadlinux-dev-6a096871b2bedd524ce706aa687de4f7145f535c.tar.xz
linux-dev-6a096871b2bedd524ce706aa687de4f7145f535c.zip
hwmon: (ibmpowernv) 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> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/ibmpowernv.c')
-rw-r--r--drivers/hwmon/ibmpowernv.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/hwmon/ibmpowernv.c b/drivers/hwmon/ibmpowernv.c
index 0e525cfbdfc5..a750647e66a4 100644
--- a/drivers/hwmon/ibmpowernv.c
+++ b/drivers/hwmon/ibmpowernv.c
@@ -186,7 +186,7 @@ static void make_sensor_label(struct device_node *np,
u32 id;
size_t n;
- n = snprintf(sdata->label, sizeof(sdata->label), "%s", label);
+ n = scnprintf(sdata->label, sizeof(sdata->label), "%s", label);
/*
* Core temp pretty print
@@ -199,11 +199,11 @@ static void make_sensor_label(struct device_node *np,
* The digital thermal sensors are associated
* with a core.
*/
- n += snprintf(sdata->label + n,
+ n += scnprintf(sdata->label + n,
sizeof(sdata->label) - n, " %d",
cpuid);
else
- n += snprintf(sdata->label + n,
+ n += scnprintf(sdata->label + n,
sizeof(sdata->label) - n, " phy%d", id);
}
@@ -211,7 +211,7 @@ static void make_sensor_label(struct device_node *np,
* Membuffer pretty print
*/
if (!of_property_read_u32(np, "ibm,chip-id", &id))
- n += snprintf(sdata->label + n, sizeof(sdata->label) - n,
+ n += scnprintf(sdata->label + n, sizeof(sdata->label) - n,
" %d", id & 0xffff);
}