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 242bce1..533981d 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))