net: liquidio: fix a NULL pointer dereference
authorKangjie Lu <kjlu@umn.edu>
Mon, 11 Mar 2019 05:02:32 +0000 (00:02 -0500)
committerDavid S. Miller <davem@davemloft.net>
Mon, 11 Mar 2019 18:43:39 +0000 (11:43 -0700)
In case octeon_alloc_soft_command fails, the fix reports the
error and returns to avoid NULL pointer dereference.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/cavium/liquidio/lio_main.c

index 9b7819fdc9ded2e3f166107f09719aa2b43a94ba..fb6f813cff65dcb7f608d4e1b859be9f38a6b13d 100644 (file)
@@ -1192,6 +1192,11 @@ static void send_rx_ctrl_cmd(struct lio *lio, int start_stop)
        sc = (struct octeon_soft_command *)
                octeon_alloc_soft_command(oct, OCTNET_CMD_SIZE,
                                          16, 0);
+       if (!sc) {
+               netif_info(lio, rx_err, lio->netdev,
+                          "Failed to allocate octeon_soft_command\n");
+               return;
+       }
 
        ncmd = (union octnet_cmd *)sc->virtdptr;