• Finn Thain's avatar
    net/sonic: Fix receive buffer replenishment · 89ba879e
    Finn Thain authored
    As soon as the driver is finished with a receive buffer it allocs a new
    one and overwrites the corresponding RRA entry with a new buffer pointer.
    
    Problem is, the buffer pointer is split across two word-sized registers.
    It can't be updated in one atomic store. So this operation races with the
    chip while it stores received packets and advances its RRP register.
    This could result in memory corruption by a DMA write.
    
    Avoid this problem by adding buffers only at the location given by the
    RWP register, in accordance with the National Semiconductor datasheet.
    
    Re-factor this code into separate functions to calculate a RRA pointer
    and to update the RWP.
    
    Fixes: efcce839 ("[PATCH] macsonic/jazzsonic network drivers update")
    Tested-by: default avatarStan Johnson <userm57@yahoo.com>
    Signed-off-by: default avatarFinn Thain <fthain@telegraphics.com.au>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    89ba879e
sonic.c 22.3 KB