* [PATCH] libata: prevent devices with blank model names from being DMA blacklisted
@ 2007-10-14 20:53 Andrew Paprocki
2007-10-15 19:41 ` Jeff Garzik
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Paprocki @ 2007-10-14 20:53 UTC (permalink / raw)
To: linux-ide; +Cc: Alan Cox, Jeff Garzik
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>
---
drivers/ata/libata-core.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 4e11e39..e73b7b4 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -4013,8 +4013,19 @@ 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 the model name parameter is empty, it should not match
+ * against anything other than "*" or "".
+ */
+ if (unlikely(len == 0)) {
+ /* In the rare case your pattern is "". */
+ if (strlen(patt) == 0)
+ return 0;
+ else
+ return -1;
+ }
+ }
return strncmp(patt, name, len);
}
--
1.5.3.4.g58ba4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] libata: prevent devices with blank model names from being DMA blacklisted
2007-10-14 20:53 [PATCH] libata: prevent devices with blank model names from being DMA blacklisted Andrew Paprocki
@ 2007-10-15 19:41 ` Jeff Garzik
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Garzik @ 2007-10-15 19:41 UTC (permalink / raw)
To: Andrew Paprocki; +Cc: linux-ide, Alan Cox
Andrew Paprocki wrote:
> 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>
> ---
> drivers/ata/libata-core.c | 13 ++++++++++++-
> 1 files changed, 12 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
> index 4e11e39..e73b7b4 100644
> --- a/drivers/ata/libata-core.c
> +++ b/drivers/ata/libata-core.c
> @@ -4013,8 +4013,19 @@ 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 the model name parameter is empty, it should not match
> + * against anything other than "*" or "".
> + */
> + if (unlikely(len == 0)) {
> + /* In the rare case your pattern is "". */
> + if (strlen(patt) == 0)
> + return 0;
> + else
> + return -1;
> + }
> + }
applied manually, patch was corrupted
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-10-15 19:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-14 20:53 [PATCH] libata: prevent devices with blank model names from being DMA blacklisted Andrew Paprocki
2007-10-15 19:41 ` Jeff Garzik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).