]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - net/core/sock.c
net: avoid limits overflow
[karo-tx-linux.git] / net / core / sock.c
index 3eed5424e659a1ab130324d16bfe3c0af4ab2feb..fb6080111461546953b34979db77f5e2d516e060 100644 (file)
@@ -1653,10 +1653,10 @@ int __sk_mem_schedule(struct sock *sk, int size, int kind)
 {
        struct proto *prot = sk->sk_prot;
        int amt = sk_mem_pages(size);
-       int allocated;
+       long allocated;
 
        sk->sk_forward_alloc += amt * SK_MEM_QUANTUM;
-       allocated = atomic_add_return(amt, prot->memory_allocated);
+       allocated = atomic_long_add_return(amt, prot->memory_allocated);
 
        /* Under limit. */
        if (allocated <= prot->sysctl_mem[0]) {
@@ -1714,7 +1714,7 @@ suppress_allocation:
 
        /* Alas. Undo changes. */
        sk->sk_forward_alloc -= amt * SK_MEM_QUANTUM;
-       atomic_sub(amt, prot->memory_allocated);
+       atomic_long_sub(amt, prot->memory_allocated);
        return 0;
 }
 EXPORT_SYMBOL(__sk_mem_schedule);
@@ -1727,12 +1727,12 @@ void __sk_mem_reclaim(struct sock *sk)
 {
        struct proto *prot = sk->sk_prot;
 
-       atomic_sub(sk->sk_forward_alloc >> SK_MEM_QUANTUM_SHIFT,
+       atomic_long_sub(sk->sk_forward_alloc >> SK_MEM_QUANTUM_SHIFT,
                   prot->memory_allocated);
        sk->sk_forward_alloc &= SK_MEM_QUANTUM - 1;
 
        if (prot->memory_pressure && *prot->memory_pressure &&
-           (atomic_read(prot->memory_allocated) < prot->sysctl_mem[0]))
+           (atomic_long_read(prot->memory_allocated) < prot->sysctl_mem[0]))
                *prot->memory_pressure = 0;
 }
 EXPORT_SYMBOL(__sk_mem_reclaim);
@@ -2452,12 +2452,12 @@ static char proto_method_implemented(const void *method)
 
 static void proto_seq_printf(struct seq_file *seq, struct proto *proto)
 {
-       seq_printf(seq, "%-9s %4u %6d  %6d   %-3s %6u   %-3s  %-10s "
+       seq_printf(seq, "%-9s %4u %6d  %6ld   %-3s %6u   %-3s  %-10s "
                        "%2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c\n",
                   proto->name,
                   proto->obj_size,
                   sock_prot_inuse_get(seq_file_net(seq), proto),
-                  proto->memory_allocated != NULL ? atomic_read(proto->memory_allocated) : -1,
+                  proto->memory_allocated != NULL ? atomic_long_read(proto->memory_allocated) : -1L,
                   proto->memory_pressure != NULL ? *proto->memory_pressure ? "yes" : "no" : "NI",
                   proto->max_header,
                   proto->slab == NULL ? "no" : "yes",