Skip to content

Commit

Permalink
lib/dma-debug.c: fix __hash_bucket_find()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reported-by: Wu Fengguang <[email protected]>
Cc: Joerg Roedel <[email protected]>
Tested-by: Shuah Khan <[email protected]>
Cc: Paul Gortmaker <[email protected]>
Cc: Jakub Kicinski <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Ming Lei authored and torvalds committed Oct 19, 2012
1 parent 0db63d7 commit fe73fbe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/dma-debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,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))
Expand Down Expand Up @@ -293,7 +293,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;
Expand Down

0 comments on commit fe73fbe

Please sign in to comment.