]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
hwmon: (stts751) Fix buffer size passed to snprintf
authorJean Delvare <jdelvare@suse.de>
Tue, 19 Sep 2017 12:59:34 +0000 (14:59 +0200)
committerGuenter Roeck <linux@roeck-us.net>
Mon, 30 Oct 2017 01:36:03 +0000 (18:36 -0700)
Function snprintf already cares for the terminating NUL at the end of
the string, the caller doesn't need to do it.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Cc: Andrea Merello <andrea.merello@gmail.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/stts751.c

index 3f940fb67dc622cc096745b9e6950e68f73d6b73..7fe152d92350e18b6c972ebcf0a7f0be0bbf94e4 100644 (file)
@@ -396,7 +396,7 @@ static ssize_t show_max_alarm(struct device *dev, struct device_attribute *attr,
        if (ret < 0)
                return ret;
 
-       return snprintf(buf, PAGE_SIZE - 1, "%d\n", priv->max_alert);
+       return snprintf(buf, PAGE_SIZE, "%d\n", priv->max_alert);
 }
 
 static ssize_t show_min_alarm(struct device *dev, struct device_attribute *attr,
@@ -413,7 +413,7 @@ static ssize_t show_min_alarm(struct device *dev, struct device_attribute *attr,
        if (ret < 0)
                return ret;
 
-       return snprintf(buf, PAGE_SIZE - 1, "%d\n", priv->min_alert);
+       return snprintf(buf, PAGE_SIZE, "%d\n", priv->min_alert);
 }
 
 static ssize_t show_input(struct device *dev, struct device_attribute *attr,
@@ -428,7 +428,7 @@ static ssize_t show_input(struct device *dev, struct device_attribute *attr,
        if (ret < 0)
                return ret;
 
-       return snprintf(buf, PAGE_SIZE - 1, "%d\n", priv->temp);
+       return snprintf(buf, PAGE_SIZE, "%d\n", priv->temp);
 }
 
 static ssize_t show_therm(struct device *dev, struct device_attribute *attr,
@@ -436,7 +436,7 @@ static ssize_t show_therm(struct device *dev, struct device_attribute *attr,
 {
        struct stts751_priv *priv = dev_get_drvdata(dev);
 
-       return snprintf(buf, PAGE_SIZE - 1, "%d\n", priv->therm);
+       return snprintf(buf, PAGE_SIZE, "%d\n", priv->therm);
 }
 
 static ssize_t set_therm(struct device *dev, struct device_attribute *attr,
@@ -478,7 +478,7 @@ static ssize_t show_hyst(struct device *dev, struct device_attribute *attr,
 {
        struct stts751_priv *priv = dev_get_drvdata(dev);
 
-       return snprintf(buf, PAGE_SIZE - 1, "%d\n", priv->hyst);
+       return snprintf(buf, PAGE_SIZE, "%d\n", priv->hyst);
 }
 
 static ssize_t set_hyst(struct device *dev, struct device_attribute *attr,
@@ -518,7 +518,7 @@ static ssize_t show_therm_trip(struct device *dev,
        if (ret < 0)
                return ret;
 
-       return snprintf(buf, PAGE_SIZE - 1, "%d\n", priv->therm_trip);
+       return snprintf(buf, PAGE_SIZE, "%d\n", priv->therm_trip);
 }
 
 static ssize_t show_max(struct device *dev, struct device_attribute *attr,
@@ -526,7 +526,7 @@ static ssize_t show_max(struct device *dev, struct device_attribute *attr,
 {
        struct stts751_priv *priv = dev_get_drvdata(dev);
 
-       return snprintf(buf, PAGE_SIZE - 1, "%d\n", priv->event_max);
+       return snprintf(buf, PAGE_SIZE, "%d\n", priv->event_max);
 }
 
 static ssize_t set_max(struct device *dev, struct device_attribute *attr,
@@ -560,7 +560,7 @@ static ssize_t show_min(struct device *dev, struct device_attribute *attr,
 {
        struct stts751_priv *priv = dev_get_drvdata(dev);
 
-       return snprintf(buf, PAGE_SIZE - 1, "%d\n", priv->event_min);
+       return snprintf(buf, PAGE_SIZE, "%d\n", priv->event_min);
 }
 
 static ssize_t set_min(struct device *dev, struct device_attribute *attr,
@@ -594,7 +594,7 @@ static ssize_t show_interval(struct device *dev, struct device_attribute *attr,
 {
        struct stts751_priv *priv = dev_get_drvdata(dev);
 
-       return snprintf(buf, PAGE_SIZE - 1, "%d\n",
+       return snprintf(buf, PAGE_SIZE, "%d\n",
                        stts751_intervals[priv->interval]);
 }