]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
packet: Don't check frames_per_block against negative values
authorTobias Klauser <tklauser@distanz.ch>
Tue, 17 Nov 2015 09:38:36 +0000 (10:38 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 17 Nov 2015 20:25:44 +0000 (15:25 -0500)
rb->frames_per_block is an unsigned int, thus can never be negative.

Also fix spacing in the calculation of frames_per_block.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/packet/af_packet.c

index 242bce1cf0f3a66b1806469ab3e733363638cbf2..533981d49290d471a89483b90ac89a7404a42e6e 100644 (file)
@@ -4121,8 +4121,8 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
                if (unlikely(req->tp_frame_size & (TPACKET_ALIGNMENT - 1)))
                        goto out;
 
-               rb->frames_per_block = req->tp_block_size/req->tp_frame_size;
-               if (unlikely(rb->frames_per_block <= 0))
+               rb->frames_per_block = req->tp_block_size / req->tp_frame_size;
+               if (unlikely(rb->frames_per_block == 0))
                        goto out;
                if (unlikely((rb->frames_per_block * req->tp_block_nr) !=
                                        req->tp_frame_nr))