PATCH: ide-proc - fix crash on identify

From: Alan Cox (alan@lxorguk.ukuu.org.uk)
Date: Tue Feb 18 2003 - 13:08:59 EST


We cannot do an identify on a drive with no driver loaded. The kernel
has a ton of half backed "if no driver" cases but they dont cover all
cases and its a mess.

For now we rely on the probe time identify unless a driver is loaded. A
proper fix (an 'ide-unassigned' driver) will follow later

diff -u --new-file --recursive --exclude-from /usr/src/exclude linux-2.5.61/drivers/ide/ide-proc.c linux-2.5.61-ac2/drivers/ide/ide-proc.c
--- linux-2.5.61/drivers/ide/ide-proc.c 2003-02-10 18:38:42.000000000 +0000
+++ linux-2.5.61-ac2/drivers/ide/ide-proc.c 2003-02-18 18:06:17.000000000 +0000
@@ -407,20 +407,40 @@
 {
         ide_drive_t *drive = (ide_drive_t *)data;
         int len = 0, i = 0;
+ int err = 0;
 
- if (drive && !taskfile_lib_get_identify(drive, page)) {
+ len = sprintf(page, "\n");
+
+ if (drive)
+ {
                 unsigned short *val = (unsigned short *) page;
- char *out = ((char *)val) + (SECTOR_WORDS * 4);
- page = out;
- do {
- out += sprintf(out, "%04x%c",
- le16_to_cpu(*val), (++i & 7) ? ' ' : '\n');
- val += 1;
- } while (i < (SECTOR_WORDS * 2));
- len = out - page;
+
+ /*
+ * The current code can't handle a driverless
+ * identify query taskfile. Now the right fix is
+ * to add a 'default' driver but that is a bit
+ * more work.
+ *
+ * FIXME: this has to be fixed for hotswap devices
+ */
+
+ if(DRIVER(drive))
+ err = taskfile_lib_get_identify(drive, page);
+ else /* This relies on the ID changes */
+ val = (unsigned short *)drive->id;
+
+ if(!err)
+ {
+ char *out = ((char *)page) + (SECTOR_WORDS * 4);
+ page = out;
+ do {
+ out += sprintf(out, "%04x%c",
+ le16_to_cpu(*val), (++i & 7) ? ' ' : '\n');
+ val += 1;
+ } while (i < (SECTOR_WORDS * 2));
+ len = out - page;
+ }
         }
- else
- len = sprintf(page, "\n");
         PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
 }
 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Feb 23 2003 - 22:00:22 EST