PATCH: ide-proc - fix crash on identify

PATCH: ide-proc - fix crash on identify

Post by Alan Co » Wed, 19 Feb 2003 20:20:17



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

 {
        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

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

1. PATCH: fix proc handling in serverworks and sc1200 ide

diff -u --new-file --recursive --exclude-from /usr/src/exclude linux-2.5.65/drivers/ide/pci/sc1200.c linux-2.5.65-ac2/drivers/ide/pci/sc1200.c
--- linux-2.5.65/drivers/ide/pci/sc1200.c       2003-03-03 19:20:09.000000000 +0000

 {
        char *p = buffer;
        unsigned long bibma = pci_resource_start(bmide_dev, 4);
+       int len;
        u8  c0 = 0, c1 = 0;


        p += sprintf(p, "DMA\n");
        p += sprintf(p, "PIO\n");

-       return p-buffer;
+       len = (p - buffer) - offset;
+       *addr = buffer + offset;
+      
+       return len > count ? count : len;
 }
 #endif /* DISPLAY_SC1200_TIMINGS && CONFIG_PROC_FS */

diff -u --new-file --recursive --exclude-from /usr/src/exclude linux-2.5.65/drivers/ide/pci/serverworks.c linux-2.5.65-ac2/drivers/ide/pci/serverworks.c
--- linux-2.5.65/drivers/ide/pci/serverworks.c  2003-03-03 19:20:09.000000000 +0000

 static int svwks_get_info (char *buffer, char **addr, off_t offset, int count)
 {
        char *p = buffer;
-       int i;
+       int i, len;

        p += sprintf(p, "\n                             "

        }
        p += sprintf(p, "\n");

-       return p-buffer;         /* => must be less than 4k! */
+       /* p - buffer must be less than 4k! */
+       len = (p - buffer) - offset;
+       *addr = buffer + offset;
+      
+       return len > count ? count : len;
 }
 #endif  /* defined(DISPLAY_SVWKS_TIMINGS) && defined(CONFIG_PROC_FS) */

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

2. gateway using linux

3. PATCH: fix /proc for amd ide

4. Help: can't switch shells...

5. PATCH: fix ALi 32bitisms, fix ALi FIFO, fix ALi IRQ crash

6. Which Should Hobbyist Run: Linux/Solaris?

7. PATCH: add new settings locks to ide-proc

8. New or Revised TAs on websco, 970326

9. 2.5.8-dj1 reading /proc/ide/.../identify

10. /proc/ide/hda/identify

11. [PATCH] /proc/interrupts fixes

12. PATCH: fix more proc and other oddments

13. PATCH: fix proc handling in sis, siimageand slc90e66