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>] [day] [month] [year] [list]
Message-Id: <1350611647-15023-1-git-send-email-ming.lei@canonical.com>
Date:	Fri, 19 Oct 2012 09:54:07 +0800
From:	Ming Lei <ming.lei@...onical.com>
To:	linux-kernel@...r.kernel.org
Cc:	Ming Lei <ming.lei@...onical.com>,
	Joerg Roedel <joerg.roedel@....com>,
	Shuah Khan <shuah.khan@...com>,
	Paul Gortmaker <paul.gortmaker@...driver.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Jakub Kicinski <kubakici@...pl>,
	Fengguang Wu <fengguang.wu@...el.com>
Subject: [PATCH v1] lib/dma-debug.c: fix __hash_bucket_find

If there is only one match, the unique matched entry should be returned.

Without the fix, the commit f62566214fe31c9f9b3218a42f1b19e6a9e6844a

	dma-debug: new interfaces to debug dma mapping errors

can't work reliably because only device and dma_addr are passed to
dma_mapping_error().

Cc: Joerg Roedel <joerg.roedel@....com>
Cc: Shuah Khan <shuah.khan@...com>
Cc: Paul Gortmaker <paul.gortmaker@...driver.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Jakub Kicinski <kubakici@...pl>
Cc: Fengguang Wu <fengguang.wu@...el.com>
Tested-by: Shuah Khan <shuah.khan@...com>
Signed-off-by: Ming Lei <ming.lei@...onical.com>
---
v1:
	- initialize 'last_lvl' as -1 to simplify the fix

 lib/dma-debug.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 94aa94e..59f4a1a 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -277,7 +277,7 @@ static struct dma_debug_entry *__hash_bucket_find(struct hash_bucket *bucket,
 						  match_fn match)
 {
 	struct dma_debug_entry *entry, *ret = NULL;
-	int matches = 0, match_lvl, last_lvl = 0;
+	int matches = 0, match_lvl, last_lvl = -1;
 
 	list_for_each_entry(entry, &bucket->list, list) {
 		if (!match(ref, entry))
@@ -306,7 +306,7 @@ static struct dma_debug_entry *__hash_bucket_find(struct hash_bucket *bucket,
 		} else if (match_lvl > last_lvl) {
 			/*
 			 * We found an entry that fits better then the
-			 * previous one
+			 * previous one or it is the 1st match.
 			 */
 			last_lvl = match_lvl;
 			ret      = entry;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ