batman-adv: Directly check read of icmp packet in copy_from_user
authorSven Eckelmann <sven@narfation.org>
Sat, 10 Dec 2011 14:28:35 +0000 (15:28 +0100)
committerMarek Lindner <lindner_marek@yahoo.de>
Mon, 12 Dec 2011 11:11:06 +0000 (19:11 +0800)
The access_ok read check can be directly done in copy_from_user since a failure
of access_ok is handled the same way as an error in __copy_from_user.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
net/batman-adv/icmp_socket.c

index 88ab26f5f7269a347421957cec4552f22396ac73..3b04fff3ede387c54ab382a0c563f1b1b8656d03 100644 (file)
@@ -187,12 +187,7 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
        skb_reserve(skb, sizeof(struct ethhdr));
        icmp_packet = (struct icmp_packet_rr *)skb_put(skb, packet_len);
 
-       if (!access_ok(VERIFY_READ, buff, packet_len)) {
-               len = -EFAULT;
-               goto free_skb;
-       }
-
-       if (__copy_from_user(icmp_packet, buff, packet_len)) {
+       if (copy_from_user(icmp_packet, buff, packet_len)) {
                len = -EFAULT;
                goto free_skb;
        }