ath9k: snprintf() returns largish values
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / ath / ath9k / htc_drv_main.c
index 32438771ca2b0218f27033443d48578140236222..cf9bcc67ade2ea0f8c8a34b1d605c5e91cda2772 100644 (file)
@@ -524,6 +524,9 @@ static ssize_t read_file_tgt_stats(struct file *file, char __user *user_buf,
        len += snprintf(buf + len, sizeof(buf) - len,
                        "%19s : %10u\n", "TX Rate", priv->debug.txrate);
 
+       if (len > sizeof(buf))
+               len = sizeof(buf);
+
        return simple_read_from_buffer(user_buf, count, ppos, buf, len);
 }
 
@@ -569,6 +572,9 @@ static ssize_t read_file_xmit(struct file *file, char __user *user_buf,
                        "%20s : %10u\n", "VO queued",
                        priv->debug.tx_stats.queue_stats[WME_AC_VO]);
 
+       if (len > sizeof(buf))
+               len = sizeof(buf);
+
        return simple_read_from_buffer(user_buf, count, ppos, buf, len);
 }
 
@@ -595,6 +601,9 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf,
                        "%20s : %10u\n", "SKBs Dropped",
                        priv->debug.rx_stats.skb_dropped);
 
+       if (len > sizeof(buf))
+               len = sizeof(buf);
+
        return simple_read_from_buffer(user_buf, count, ppos, buf, len);
 }