gve: fix -ENOMEM null check on a page allocation
authorColin Ian King <colin.king@canonical.com>
Wed, 3 Jul 2019 16:50:37 +0000 (17:50 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 3 Jul 2019 20:53:07 +0000 (13:53 -0700)
Currently the check to see if a page is allocated is incorrect
and is checking if the pointer page is null, not *page as
intended.  Fix this.

Addresses-Coverity: ("Dereference before null check")
Fixes: f5cedc84a30d ("gve: Add transmit and receive support")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/google/gve/gve_main.c

index 83f65a5a9a3fc98740613f167dbbc3ccea119615..eef500bd2ff7283463e671e9382e677976a30d31 100644 (file)
@@ -518,7 +518,7 @@ int gve_alloc_page(struct device *dev, struct page **page, dma_addr_t *dma,
                   enum dma_data_direction dir)
 {
        *page = alloc_page(GFP_KERNEL);
-       if (!page)
+       if (!*page)
                return -ENOMEM;
        *dma = dma_map_page(dev, *page, 0, PAGE_SIZE, dir);
        if (dma_mapping_error(dev, *dma)) {