aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKangjie Lu <kjlu@umn.edu>2019-03-11 02:01:41 -0400
committerDavid S. Miller <davem@davemloft.net>2019-03-11 15:29:17 -0400
commit41af8b3a097c6fd17a4867efa25966927094f57c (patch)
tree07c6516a7ffb0278eef8bc6d40bac6eab72eb028
parentdd9d9f5907bb475f8b1796c47d4ecc7fb9b72136 (diff)
net: lio_core: fix two NULL pointer dereferences
In case octeon_alloc_soft_command fails, the fix reports the error and returns to avoid NULL pointer dereferences. Signed-off-by: Kangjie Lu <kjlu@umn.edu> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/cavium/liquidio/lio_core.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_core.c b/drivers/net/ethernet/cavium/liquidio/lio_core.c
index e21bf3724611..1c50c10b5a16 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_core.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_core.c
@@ -1211,6 +1211,11 @@ int liquidio_change_mtu(struct net_device *netdev, int new_mtu)
1211 1211
1212 sc = (struct octeon_soft_command *) 1212 sc = (struct octeon_soft_command *)
1213 octeon_alloc_soft_command(oct, OCTNET_CMD_SIZE, 16, 0); 1213 octeon_alloc_soft_command(oct, OCTNET_CMD_SIZE, 16, 0);
1214 if (!sc) {
1215 netif_info(lio, rx_err, lio->netdev,
1216 "Failed to allocate soft command\n");
1217 return -ENOMEM;
1218 }
1214 1219
1215 ncmd = (union octnet_cmd *)sc->virtdptr; 1220 ncmd = (union octnet_cmd *)sc->virtdptr;
1216 1221
@@ -1684,6 +1689,11 @@ int liquidio_set_fec(struct lio *lio, int on_off)
1684 1689
1685 sc = octeon_alloc_soft_command(oct, OCTNET_CMD_SIZE, 1690 sc = octeon_alloc_soft_command(oct, OCTNET_CMD_SIZE,
1686 sizeof(struct oct_nic_seapi_resp), 0); 1691 sizeof(struct oct_nic_seapi_resp), 0);
1692 if (!sc) {
1693 dev_err(&oct->pci_dev->dev,
1694 "Failed to allocate soft command\n");
1695 return -ENOMEM;
1696 }
1687 1697
1688 ncmd = sc->virtdptr; 1698 ncmd = sc->virtdptr;
1689 resp = sc->virtrptr; 1699 resp = sc->virtrptr;