netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: lio_core: fix two NULL pointer dereferences
@ 2019-03-11  6:01 Kangjie Lu
  2019-03-11 19:29 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Kangjie Lu @ 2019-03-11  6:01 UTC (permalink / raw)
  To: kjlu
  Cc: pakki001, Derek Chickles, Satanand Burla, Felix Manlunas,
	David S. Miller, netdev, linux-kernel

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>
---
 drivers/net/ethernet/cavium/liquidio/lio_core.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

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)
 
 	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 soft command\n");
+		return -ENOMEM;
+	}
 
 	ncmd = (union octnet_cmd *)sc->virtdptr;
 
@@ -1684,6 +1689,11 @@ int liquidio_set_fec(struct lio *lio, int on_off)
 
 	sc = octeon_alloc_soft_command(oct, OCTNET_CMD_SIZE,
 				       sizeof(struct oct_nic_seapi_resp), 0);
+	if (!sc) {
+		dev_err(&oct->pci_dev->dev,
+			"Failed to allocate soft command\n");
+		return -ENOMEM;
+	}
 
 	ncmd = sc->virtdptr;
 	resp = sc->virtrptr;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: lio_core: fix two NULL pointer dereferences
  2019-03-11  6:01 [PATCH] net: lio_core: fix two NULL pointer dereferences Kangjie Lu
@ 2019-03-11 19:29 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-03-11 19:29 UTC (permalink / raw)
  To: kjlu; +Cc: pakki001, dchickles, sburla, fmanlunas, netdev, linux-kernel

From: Kangjie Lu <kjlu@umn.edu>
Date: Mon, 11 Mar 2019 01:01:41 -0500

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

Applied, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-03-11 19:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-11  6:01 [PATCH] net: lio_core: fix two NULL pointer dereferences Kangjie Lu
2019-03-11 19:29 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).