• Finn Thain's avatar
    net/sonic: Fix receive buffer replenishment · 7d8c24e0
    Finn Thain authored
    commit 89ba879e upstream.
    
    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>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    7d8c24e0
sonic.c 22.2 KB