diff mbox series

[v2] net: liquidio: fix a NULL pointer dereference

Message ID 20190311050232.3250-1-kjlu@umn.edu
State Accepted
Delegated to: David Miller
Headers show
Series [v2] net: liquidio: fix a NULL pointer dereference | expand

Commit Message

Kangjie Lu March 11, 2019, 5:02 a.m. UTC
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>
---
 drivers/net/ethernet/cavium/liquidio/lio_main.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

David Miller March 11, 2019, 6:44 p.m. UTC | #1
From: Kangjie Lu <kjlu@umn.edu>
Date: Mon, 11 Mar 2019 00:02:32 -0500

> 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>

Applied.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index 9b7819fdc9de..fb6f813cff65 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -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;