• Andre Przywara's avatar
    net: axienet: Fix DMA descriptor cleanup path · f26667a3
    Andre Przywara authored
    When axienet_dma_bd_init() bails out during the initialisation process,
    it might do so with parts of the structure already allocated and
    initialised, while other parts have not been touched yet. Before
    returning in this case, we call axienet_dma_bd_release(), which does not
    take care of this corner case.
    This is most obvious by the first loop happily dereferencing
    lp->rx_bd_v, which we actually check to be non NULL *afterwards*.
    
    Make sure we only unmap or free already allocated structures, by:
    - directly returning with -ENOMEM if nothing has been allocated at all
    - checking for lp->rx_bd_v to be non-NULL *before* using it
    - only unmapping allocated DMA RX regions
    
    This avoids NULL pointer dereferences when initialisation fails.
    Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    f26667a3
xilinx_axienet_main.c 56.3 KB