Skip to content

Commit

Permalink
libata: prevent devices with blank model names from being DMA blackli…
Browse files Browse the repository at this point in the history
…sted

The strn_pattern_cmp routine does not handle a blank name parameter
properly. The only patterns which should match a blank name are "*"
and an explicit "". If the function is passed a blank name in current
code, it will always match against the patt parameter. The bug manifests
itself as the device with the empty model name always matching the first
device in the DMA blacklist, forcing it to revert to PIO mode.

Signed-off-by: Andrew Paprocki <andrew@ishiboo.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
  • Loading branch information
Andrew Paprocki authored and Jeff Garzik committed Oct 15, 2007
1 parent 8f73a68 commit 317b50b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/ata/libata-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -4014,8 +4014,14 @@ int strn_pattern_cmp(const char *patt, const char *name, int wildchar)
p = strchr(patt, wildchar);
if (p && ((*(p + 1)) == 0))
len = p - patt;
else
else {
len = strlen(name);
if (!len) {
if (!*patt)
return 0;
return -1;
}
}

return strncmp(patt, name, len);
}
Expand Down

0 comments on commit 317b50b

Please sign in to comment.