diff options
Diffstat (limited to 'net/core/pktgen.c')
-rw-r--r-- | net/core/pktgen.c | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index 2c0df0f95b3d..33bc3823ac6f 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
@@ -771,10 +771,10 @@ done: | |||
771 | static unsigned long num_arg(const char __user * user_buffer, | 771 | static unsigned long num_arg(const char __user * user_buffer, |
772 | unsigned long maxlen, unsigned long *num) | 772 | unsigned long maxlen, unsigned long *num) |
773 | { | 773 | { |
774 | int i = 0; | 774 | int i; |
775 | *num = 0; | 775 | *num = 0; |
776 | 776 | ||
777 | for (; i < maxlen; i++) { | 777 | for (i = 0; i < maxlen; i++) { |
778 | char c; | 778 | char c; |
779 | if (get_user(c, &user_buffer[i])) | 779 | if (get_user(c, &user_buffer[i])) |
780 | return -EFAULT; | 780 | return -EFAULT; |
@@ -789,9 +789,9 @@ static unsigned long num_arg(const char __user * user_buffer, | |||
789 | 789 | ||
790 | static int strn_len(const char __user * user_buffer, unsigned int maxlen) | 790 | static int strn_len(const char __user * user_buffer, unsigned int maxlen) |
791 | { | 791 | { |
792 | int i = 0; | 792 | int i; |
793 | 793 | ||
794 | for (; i < maxlen; i++) { | 794 | for (i = 0; i < maxlen; i++) { |
795 | char c; | 795 | char c; |
796 | if (get_user(c, &user_buffer[i])) | 796 | if (get_user(c, &user_buffer[i])) |
797 | return -EFAULT; | 797 | return -EFAULT; |
@@ -846,7 +846,7 @@ static ssize_t pktgen_if_write(struct file *file, | |||
846 | { | 846 | { |
847 | struct seq_file *seq = file->private_data; | 847 | struct seq_file *seq = file->private_data; |
848 | struct pktgen_dev *pkt_dev = seq->private; | 848 | struct pktgen_dev *pkt_dev = seq->private; |
849 | int i = 0, max, len; | 849 | int i, max, len; |
850 | char name[16], valstr[32]; | 850 | char name[16], valstr[32]; |
851 | unsigned long value = 0; | 851 | unsigned long value = 0; |
852 | char *pg_result = NULL; | 852 | char *pg_result = NULL; |
@@ -860,13 +860,13 @@ static ssize_t pktgen_if_write(struct file *file, | |||
860 | return -EINVAL; | 860 | return -EINVAL; |
861 | } | 861 | } |
862 | 862 | ||
863 | max = count - i; | 863 | max = count; |
864 | tmp = count_trail_chars(&user_buffer[i], max); | 864 | tmp = count_trail_chars(user_buffer, max); |
865 | if (tmp < 0) { | 865 | if (tmp < 0) { |
866 | pr_warning("illegal format\n"); | 866 | pr_warning("illegal format\n"); |
867 | return tmp; | 867 | return tmp; |
868 | } | 868 | } |
869 | i += tmp; | 869 | i = tmp; |
870 | 870 | ||
871 | /* Read variable name */ | 871 | /* Read variable name */ |
872 | 872 | ||
@@ -887,10 +887,11 @@ static ssize_t pktgen_if_write(struct file *file, | |||
887 | i += len; | 887 | i += len; |
888 | 888 | ||
889 | if (debug) { | 889 | if (debug) { |
890 | char tb[count + 1]; | 890 | size_t copy = min_t(size_t, count, 1023); |
891 | if (copy_from_user(tb, user_buffer, count)) | 891 | char tb[copy + 1]; |
892 | if (copy_from_user(tb, user_buffer, copy)) | ||
892 | return -EFAULT; | 893 | return -EFAULT; |
893 | tb[count] = 0; | 894 | tb[copy] = 0; |
894 | printk(KERN_DEBUG "pktgen: %s,%lu buffer -:%s:-\n", name, | 895 | printk(KERN_DEBUG "pktgen: %s,%lu buffer -:%s:-\n", name, |
895 | (unsigned long)count, tb); | 896 | (unsigned long)count, tb); |
896 | } | 897 | } |
@@ -1764,7 +1765,7 @@ static ssize_t pktgen_thread_write(struct file *file, | |||
1764 | { | 1765 | { |
1765 | struct seq_file *seq = file->private_data; | 1766 | struct seq_file *seq = file->private_data; |
1766 | struct pktgen_thread *t = seq->private; | 1767 | struct pktgen_thread *t = seq->private; |
1767 | int i = 0, max, len, ret; | 1768 | int i, max, len, ret; |
1768 | char name[40]; | 1769 | char name[40]; |
1769 | char *pg_result; | 1770 | char *pg_result; |
1770 | 1771 | ||
@@ -1773,12 +1774,12 @@ static ssize_t pktgen_thread_write(struct file *file, | |||
1773 | return -EINVAL; | 1774 | return -EINVAL; |
1774 | } | 1775 | } |
1775 | 1776 | ||
1776 | max = count - i; | 1777 | max = count; |
1777 | len = count_trail_chars(&user_buffer[i], max); | 1778 | len = count_trail_chars(user_buffer, max); |
1778 | if (len < 0) | 1779 | if (len < 0) |
1779 | return len; | 1780 | return len; |
1780 | 1781 | ||
1781 | i += len; | 1782 | i = len; |
1782 | 1783 | ||
1783 | /* Read variable name */ | 1784 | /* Read variable name */ |
1784 | 1785 | ||
@@ -1975,7 +1976,7 @@ static struct net_device *pktgen_dev_get_by_name(struct pktgen_dev *pkt_dev, | |||
1975 | const char *ifname) | 1976 | const char *ifname) |
1976 | { | 1977 | { |
1977 | char b[IFNAMSIZ+5]; | 1978 | char b[IFNAMSIZ+5]; |
1978 | int i = 0; | 1979 | int i; |
1979 | 1980 | ||
1980 | for (i = 0; ifname[i] != '@'; i++) { | 1981 | for (i = 0; ifname[i] != '@'; i++) { |
1981 | if (i == IFNAMSIZ) | 1982 | if (i == IFNAMSIZ) |
@@ -2519,8 +2520,8 @@ static void free_SAs(struct pktgen_dev *pkt_dev) | |||
2519 | { | 2520 | { |
2520 | if (pkt_dev->cflows) { | 2521 | if (pkt_dev->cflows) { |
2521 | /* let go of the SAs if we have them */ | 2522 | /* let go of the SAs if we have them */ |
2522 | int i = 0; | 2523 | int i; |
2523 | for (; i < pkt_dev->cflows; i++) { | 2524 | for (i = 0; i < pkt_dev->cflows; i++) { |
2524 | struct xfrm_state *x = pkt_dev->flows[i].x; | 2525 | struct xfrm_state *x = pkt_dev->flows[i].x; |
2525 | if (x) { | 2526 | if (x) { |
2526 | xfrm_state_put(x); | 2527 | xfrm_state_put(x); |
@@ -2611,8 +2612,8 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev, | |||
2611 | /* Update any of the values, used when we're incrementing various | 2612 | /* Update any of the values, used when we're incrementing various |
2612 | * fields. | 2613 | * fields. |
2613 | */ | 2614 | */ |
2614 | queue_map = pkt_dev->cur_queue_map; | ||
2615 | mod_cur_headers(pkt_dev); | 2615 | mod_cur_headers(pkt_dev); |
2616 | queue_map = pkt_dev->cur_queue_map; | ||
2616 | 2617 | ||
2617 | datalen = (odev->hard_header_len + 16) & ~0xf; | 2618 | datalen = (odev->hard_header_len + 16) & ~0xf; |
2618 | 2619 | ||
@@ -2975,8 +2976,8 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev, | |||
2975 | /* Update any of the values, used when we're incrementing various | 2976 | /* Update any of the values, used when we're incrementing various |
2976 | * fields. | 2977 | * fields. |
2977 | */ | 2978 | */ |
2978 | queue_map = pkt_dev->cur_queue_map; | ||
2979 | mod_cur_headers(pkt_dev); | 2979 | mod_cur_headers(pkt_dev); |
2980 | queue_map = pkt_dev->cur_queue_map; | ||
2980 | 2981 | ||
2981 | skb = __netdev_alloc_skb(odev, | 2982 | skb = __netdev_alloc_skb(odev, |
2982 | pkt_dev->cur_pkt_size + 64 | 2983 | pkt_dev->cur_pkt_size + 64 |