You need to sign in or sign up before continuing.
  • Tim Gardner's avatar
    net: enetc: unmap DMA in enetc_send_cmd() · cd4bc63d
    Tim Gardner authored
    Coverity complains of a possible dereference of a null return value.
    
       	5. returned_null: kzalloc returns NULL. [show details]
       	6. var_assigned: Assigning: si_data = NULL return value from kzalloc.
    488        si_data = kzalloc(data_size, __GFP_DMA | GFP_KERNEL);
    489        cbd.length = cpu_to_le16(data_size);
    490
    491        dma = dma_map_single(&priv->si->pdev->dev, si_data,
    492                             data_size, DMA_FROM_DEVICE);
    
    While this kzalloc() is unlikely to fail, I did notice that the function
    returned without unmapping si_data.
    
    Fix this by refactoring the error paths and checking for kzalloc()
    failure.
    
    Fixes: 888ae5a3
    
     ("net: enetc: add tc flower psfp offload driver")
    Cc: Claudiu Manoil <claudiu.manoil@nxp.com>
    Cc: "David S. Miller" <davem@davemloft.net>
    Cc: Jakub Kicinski <kuba@kernel.org>
    Cc: netdev@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org (open list)
    Signed-off-by: default avatarTim Gardner <tim.gardner@canonical.com>
    Acked-by: default avatarClaudiu Manoil <claudiu.manoil@nxp.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    cd4bc63d
enetc_qos.c 36.8 KB