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  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180403211505.GA29612@embeddedor.com>
Date:   Tue, 3 Apr 2018 16:15:05 -0500
From:   "Gustavo A. R. Silva" <gustavo@...eddedor.com>
To:     Zhichang Yuan <yuanzhichang@...ilicon.com>,
        Gabriele Paoloni <gabriele.paoloni@...wei.com>,
        John Garry <john.garry@...wei.com>,
        Bjorn Helgaas <bhelgaas@...gle.com>,
        Andy Shevchenko <andy.shevchenko@...il.com>
Cc:     linux-kernel@...r.kernel.org,
        "Gustavo A. R. Silva" <gustavo@...eddeodr.com>
Subject: [PATCH] lib: logic_pio: Fix potential NULL pointer dereference

new_range is being dereferenced before it is null checked, hence
there is a potential null pointer dereference.

Fix this by moving the pointer dereference after new_range has
been properly null checked.

Addresses-Coverity-ID: 1466163 ("Dereference before null check")
Fixes: 0a7198426259 ("lib: Add generic PIO mapping method")
Signed-off-by: Gustavo A. R. Silva <gustavo@...eddedor.com>
---
 lib/logic_pio.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/logic_pio.c b/lib/logic_pio.c
index 29cedea..30dfdce 100644
--- a/lib/logic_pio.c
+++ b/lib/logic_pio.c
@@ -33,8 +33,8 @@ static DEFINE_MUTEX(io_range_mutex);
 int logic_pio_register_range(struct logic_pio_hwaddr *new_range)
 {
 	struct logic_pio_hwaddr *range;
-	resource_size_t start = new_range->hw_start;
-	resource_size_t end = new_range->hw_start + new_range->size;
+	resource_size_t start;
+	resource_size_t end;
 	resource_size_t mmio_sz = 0;
 	resource_size_t iio_sz = MMIO_UPPER_LIMIT;
 	int ret = 0;
@@ -42,6 +42,9 @@ int logic_pio_register_range(struct logic_pio_hwaddr *new_range)
 	if (!new_range || !new_range->fwnode || !new_range->size)
 		return -EINVAL;
 
+	start = new_range->hw_start;
+	end = new_range->hw_start + new_range->size;
+
 	mutex_lock(&io_range_mutex);
 	list_for_each_entry_rcu(range, &io_range_list, list) {
 		if (range->fwnode == new_range->fwnode) {
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ