Skip to content

Commit fe73fbe

Browse files
Ming Leitorvalds
authored andcommitted
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 upcoming dma debug interfaces ("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(). Signed-off-by: Ming Lei <ming.lei@canonical.com> Reported-by: Wu Fengguang <fengguang.wu@intel.com> Cc: Joerg Roedel <joerg.roedel@amd.com> Tested-by: Shuah Khan <shuah.khan@hp.com> Cc: Paul Gortmaker <paul.gortmaker@windriver.com> Cc: Jakub Kicinski <kubakici@wp.pl> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 0db63d7 commit fe73fbe

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎lib/dma-debug.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ static struct dma_debug_entry *__hash_bucket_find(struct hash_bucket *bucket,
264264
match_fn match)
265265
{
266266
struct dma_debug_entry *entry, *ret = NULL;
267-
int matches = 0, match_lvl, last_lvl = 0;
267+
int matches = 0, match_lvl, last_lvl = -1;
268268

269269
list_for_each_entry(entry, &bucket->list, list) {
270270
if (!match(ref, entry))
@@ -293,7 +293,7 @@ static struct dma_debug_entry *__hash_bucket_find(struct hash_bucket *bucket,
293293
} else if (match_lvl > last_lvl) {
294294
/*
295295
* We found an entry that fits better then the
296-
* previous one
296+
* previous one or it is the 1st match.
297297
*/
298298
last_lvl = match_lvl;
299299
ret = entry;

0 commit comments

Comments
 (0)