lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 22 Mar 2019 22:24:19 -0500
From:   Kangjie Lu <kjlu@....edu>
To:     kjlu@....edu
Cc:     pakki001@....edu, Ulf Hansson <ulf.hansson@...aro.org>,
        Derek Chickles <dchickles@...vell.com>,
        Satanand Burla <sburla@...vell.com>,
        Felix Manlunas <fmanlunas@...vell.com>,
        "David S. Miller" <davem@...emloft.net>,
        Linus Walleij <linus.walleij@...aro.org>,
        Laurent Pinchart <laurent.pinchart+renesas@...asonboard.com>,
        Jonathan Neuschäfer <j.neuschaefer@....net>,
        linux-mmc@...r.kernel.org, linux-kernel@...r.kernel.org,
        netdev@...r.kernel.org
Subject: [PATCH v2] net: liquidio: fix NULL pointer dereferences

In case octeon_alloc_soft_command fails, the fix reports the
error and goes to cleanup to avoid NULL pointer dereferences.

Signed-off-by: Kangjie Lu <kjlu@....edu>
---
V2: goto setup_nic_dev_free for cleanup
---
 drivers/mmc/host/mmc_spi.c                         |  2 +-
 drivers/net/ethernet/cavium/liquidio/lio_vf_main.c | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
index 32fea585262b..a3533935e282 100644
--- a/drivers/mmc/host/mmc_spi.c
+++ b/drivers/mmc/host/mmc_spi.c
@@ -820,7 +820,7 @@ mmc_spi_readblock(struct mmc_spi_host *host, struct spi_transfer *t,
 
 	status = spi_sync_locked(spi, &host->m);
 	if (status < 0) {
-		dev_dbg(&spi->dev, "read error %02x (%d)\n", status, status);
+		dev_dbg(&spi->dev, "read error %d\n", status);
 		return status;
 	}
 
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
index 54b245797d2e..e653072846b0 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
@@ -611,6 +611,12 @@ 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;
 
@@ -1960,6 +1966,12 @@ static int setup_nic_devices(struct octeon_device *octeon_dev)
 		sc = (struct octeon_soft_command *)
 			octeon_alloc_soft_command(octeon_dev, data_size,
 						  resp_size, 0);
+		if (!sc) {
+			dev_err(&octeon_dev->pci_dev->dev,
+				"Failed to allocate octeon_soft_command\n");
+			goto setup_nic_dev_free;
+		}
+
 		resp = (struct liquidio_if_cfg_resp *)sc->virtrptr;
 		vdata = (struct lio_version *)sc->virtdptr;
 
-- 
2.17.1

Powered by blists - more mailing lists