public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* 2.4.17 panic on boot - patch for ide-pci
@ 2002-02-05 17:13 Roger Massey
  2002-02-05 17:59 ` Alex Scheele
  0 siblings, 1 reply; 2+ messages in thread
From: Roger Massey @ 2002-02-05 17:13 UTC (permalink / raw)
  To: linux-kernel

I have a kr7a-raid (hpt372 raid) motherboard.i The 2.4.17 kernel
(plus the 2.4.xx variants on the redhat 7.2 and mandrake 8.1)
panic during boot.

I have found the problem is in ide-pci.c (and a similar one in
hpt366.c) and diff -u follows below.

The code of interest begins at line 835 (2.4.17 base):
The hpt372 returns a class_rev of  5  which is not expected
by the switch statement.

        pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
        class_rev &= 0xff;

        strcpy(d->name, chipset_names[class_rev]);

        switch(class_rev) {
                case 4:
                case 3: printk("%s: IDE controller on PCI bus %02x dev
%02x\n",d->name, dev->bus->number, dev->devfn);
                        ide_setup_pci_device(dev, d);
                        return;
                default:        break;
        }

The patch makes this code more defensive by using the highest known
class_rev if one is returned which is higher.

Also, for class_rev == 4, the strcpy copies a 7 byte string over
a 6 byte one ("HPT370A" over "HPT366") so I added a strncpy
to make this more defensive as well.

Roger Massey

////////////////////////////////////////////////////////////////////////////
////////////////////////////
--- drivers/ide/ide-pci.c Mon Feb  4 19:44:02 2002
+++ drivers/ide/ide-pci.orig.c Mon Feb  4 19:37:50 2002
@@ -836,11 +836,7 @@
  pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
  class_rev &= 0xff;

- if(class_rev >= (sizeof(chipset_names)/sizeof(char *))) {
-  class_rev = (sizeof(chipset_names)/sizeof(char *)) - 1;
- }
-
- strncpy(d->name, chipset_names[class_rev], strlen(d->name));
+ strcpy(d->name, chipset_names[class_rev]);

  switch(class_rev) {
   case 4:
--- drivers/ide/hpt366.c Mon Feb  4 19:32:45 2002
+++ drivers/ide/hpt366.orig.c Mon Feb  4 19:33:30 2002
@@ -214,9 +214,6 @@
  pci_read_config_dword(bmide_dev, PCI_CLASS_REVISION, &class_rev);
  class_rev &= 0xff;

- if(class_rev >= (sizeof(chipset_names)/sizeof(char *)))
-  class_rev = (sizeof(chipset_names)/sizeof(char *)) -1;
-
         /*
          * at that point bibma+0x2 et bibma+0xa are byte registers
          * to investigate:




^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: 2.4.17 panic on boot - patch for ide-pci
  2002-02-05 17:13 2.4.17 panic on boot - patch for ide-pci Roger Massey
@ 2002-02-05 17:59 ` Alex Scheele
  0 siblings, 0 replies; 2+ messages in thread
From: Alex Scheele @ 2002-02-05 17:59 UTC (permalink / raw)
  To: Roger Massey; +Cc: Lkml

[snip]
> --- drivers/ide/ide-pci.c Mon Feb  4 19:44:02 2002
> +++ drivers/ide/ide-pci.orig.c Mon Feb  4 19:37:50 2002
> @@ -836,11 +836,7 @@
>   pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
>   class_rev &= 0xff;
> 
> - if(class_rev >= (sizeof(chipset_names)/sizeof(char *))) {
> -  class_rev = (sizeof(chipset_names)/sizeof(char *)) - 1;
> - }
> -
> - strncpy(d->name, chipset_names[class_rev], strlen(d->name));
> + strcpy(d->name, chipset_names[class_rev]);
> 
>   switch(class_rev) {
>    case 4:
> --- drivers/ide/hpt366.c Mon Feb  4 19:32:45 2002
> +++ drivers/ide/hpt366.orig.c Mon Feb  4 19:33:30 2002
> @@ -214,9 +214,6 @@
>   pci_read_config_dword(bmide_dev, PCI_CLASS_REVISION, &class_rev);
>   class_rev &= 0xff;
> 
> - if(class_rev >= (sizeof(chipset_names)/sizeof(char *)))
> -  class_rev = (sizeof(chipset_names)/sizeof(char *)) -1;
> -
>          /*
>           * at that point bibma+0x2 et bibma+0xa are byte registers
>           * to investigate:

Seems u diffed the wrong way :) original file should be first.

--
	Alex (alex@packetstorm.nu)



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-02-05 17:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-02-05 17:13 2.4.17 panic on boot - patch for ide-pci Roger Massey
2002-02-05 17:59 ` Alex Scheele

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox