ide: fix revision comparison in ide_in_drive_list
PATCH 1/1 ide: fix revision comparison in ide_in_drive_list
NB: bart/ide-2.6.git seems to be unmaintained, so I'm sending this directly to -mm
Fix ide_in_drive_list: drive_table->id_firmware should be searched *in* id->fw_rev, not vise versa.
drivers/ide/ide-dma.c +1 -1
@@ -147,7 +147,7 @@ {for ( ; drive_table->id_model ; drive_table++)if ((!strcmp (drive_table->id_model, id->model)) && - ((strstr (drive_table->id_firmware, id->fw_rev)) || + ((strstr (id->fw_rev, drive_table->id_firmware)) || (!strcmp (drive_table->id_firmware,"ALL" ))))return 1 ;return 0 ;
Quoted 13 lines · Kirill Smelkov
NB: bart/ide-2.6.git seems to be unmaintained, so I'm sending this directly to -mm
Fix
ide_in_drive_list:drive_table->id_firmwareshould be searched *in*id->fw_rev, not vise versa.Signed-off-by Kirill Smelkov <[email protected]>Index:
linux-2.6.17/drivers/ide/ide-dma.c
===================================================================
drivers/ide/ide-dma.c line 153
Quoted 8 lines
drivers/ide/ide-dma.c +1
-1@@ -147,7 +147,7 @@ {for ( ; drive_table->id_model ; drive_table++)if ((!strcmp (drive_table->id_model, id->model)) && - ((strstr (drive_table->id_firmware, id->fw_rev)) || + ((strstr (id->fw_rev, drive_table->id_firmware)) || (!strcmp (drive_table->id_firmware,"ALL" ))))return 1 ;return 0 ;
hm. This seems... rather serious. I assume that in most cases, the firmware rev which we have in the table (eg "24.09P07") is a full-string match for the string which the drive returned.
If not, you've just blacklisted a whole bunch of drives which always should have been blacklisted, but weren't.
Ar Maw, 2006-06-20 am 15:19 -0700, ysgrifennodd Andrew Morton:
Quoted 3 lines
hm. This seems... rather serious. I assume that in most cases, the firmware rev which we have in the table (eg "24.09P07") is a full-string match for the string which the drive returned.
They are full matches as far as I can see so it should be ok, plus the DMA blacklist is mostly hardware that went out ten or more years ago. Even if it did mis-trigger we'd be blacklisting extra firmware revs of iffy hardware so that isn't do worrying.
Alan
Quoted 9 lines · Alan Cox
Ar Maw, 2006-06-20 am 15:19 -0700, ysgrifennodd Andrew Morton:
Quoted 3 lines
hm. This seems... rather serious. I assume that in most cases, the firmware rev which we have in the table (eg "24.09P07") is a full-string match for the string which the drive returned.
They are full matches as far as I can see so it should be ok, plus the DMA blacklist is mostly hardware that went out ten or more years ago. Even if it did mis-trigger we'd be blacklisting extra firmware revs of iffy hardware so that isn't do worrying.
No, they are *not* full matches.
My case:
CF model="TRANSCEND", revision="20050811" as reported by "hdparm -I" and bios,
but
id->model="TRANSCEND",
id->fw_rev="20050811TRANSCEND"
note the trailing in id->fw_rev,
So lets look at ide_in_drive_list -- it should try to detect blacklisted revision, so it looks for substr device_table->id_firmware in id->fw_rev.
NB: I don't know what causes id->fw_rev to be bogus (?), but maybe the right fix
NB: is to correct its initialization. Some person with IDE background should clarify this.
Signature · 1 line
Kirill
Ar Mer, 2006-06-21 am 10:17 +0400, ysgrifennodd Kirill Smelkov:
Quoted 4 lines
id->model="TRANSCEND",
id->fw_rev="20050811TRANSCEND"note the trailing in
id->fw_rev,
These are not null terminated strings in the ident block. So if you merely print them or test against them you'll break on 8 char long firmware names. They may also be space rather than \0 padded if shorter
Alan
Quoted 8 lines · Alan Cox
Quoted 4 lines
id->model="TRANSCEND",
id->fw_rev="20050811TRANSCEND"note the trailing in
id->fw_rev,These are not null terminated strings in the ident block. So if you merely print them or test against them you'll break on 8 char long firmware names. They may also be space rather than \0 padded if shorter
This justifies strstr usage.
Thanks again.
Signature · 1 line
Kirill