* [PATCH] eeh: Fixing a bug when pci structure is null [not found] <1264789719-15591-1-git-send-email-leitao@linux.vnet.ibm.com> @ 2010-02-02 17:46 ` Breno Leitao 2010-02-02 18:05 ` Wolfram Sang 0 siblings, 1 reply; 8+ messages in thread From: Breno Leitao @ 2010-02-02 17:46 UTC (permalink / raw) To: benh, linuxppc-dev; +Cc: Linas Vepstas During a EEH recover, the pci_dev structure can be null, mainly if an eeh event is detected during cpi config operation. In this case, the pci_dev will not be known (and will be null) and the kernel will crash with the following message: Unable to handle kernel paging request for data at address 0x000000a0 Faulting instruction address: 0xc00000000006b8b4 Oops: Kernel access of bad area, sig: 11 [#1] NIP [c00000000006b8b4] .eeh_event_handler+0x10c/0x1a0 LR [c00000000006b8a8] .eeh_event_handler+0x100/0x1a0 Call Trace: [c0000003a80dff00] [c00000000006b8a8] .eeh_event_handler+0x100/0x1a0 [c0000003a80dff90] [c000000000031f1c] .kernel_thread+0x54/0x70 The bug occurs because pci_name() tries to access a null pointer. This patch just guarantee that pci_name() is not called on Null pointers. Signed-off-by: Breno Leitao <leitao@linux.vnet.ibm.com> Signed-off-by: Linas Vepstas <linasvepstas@gmail.com> --- arch/powerpc/include/asm/ppc-pci.h | 7 +++++++ arch/powerpc/platforms/pseries/eeh.c | 4 ++-- arch/powerpc/platforms/pseries/eeh_driver.c | 4 ++-- arch/powerpc/platforms/pseries/eeh_event.c | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/include/asm/ppc-pci.h b/arch/powerpc/include/asm/ppc-pci.h index 2828f9d..724dbe2 100644 --- a/arch/powerpc/include/asm/ppc-pci.h +++ b/arch/powerpc/include/asm/ppc-pci.h @@ -137,6 +137,13 @@ struct device_node * find_device_pe(struct device_node *dn); void eeh_sysfs_add_device(struct pci_dev *pdev); void eeh_sysfs_remove_device(struct pci_dev *pdev); +static inline const char *eeh_pci_name(struct pci_dev *pdev) +{ + if (NULL==pdev) + return "<null>"; + return pci_name(pdev); +} + #endif /* CONFIG_EEH */ #else /* CONFIG_PCI */ diff --git a/arch/powerpc/platforms/pseries/eeh.c b/arch/powerpc/platforms/pseries/eeh.c index ccd8dd0..f9360fe 100644 --- a/arch/powerpc/platforms/pseries/eeh.c +++ b/arch/powerpc/platforms/pseries/eeh.c @@ -491,7 +491,7 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev) pdn->eeh_mode & EEH_MODE_NOCHECK) { ignored_check++; pr_debug("EEH: Ignored check (%x) for %s %s\n", - pdn->eeh_mode, pci_name (dev), dn->full_name); + pdn->eeh_mode, eeh_pci_name (dev), dn->full_name); return 0; } @@ -515,7 +515,7 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev) printk (KERN_ERR "EEH: %d reads ignored for recovering device at " "location=%s driver=%s pci addr=%s\n", pdn->eeh_check_count, location, - dev->driver->name, pci_name(dev)); + dev->driver->name, eeh_pci_name(dev)); printk (KERN_ERR "EEH: Might be infinite loop in %s driver\n", dev->driver->name); dump_stack(); diff --git a/arch/powerpc/platforms/pseries/eeh_driver.c b/arch/powerpc/platforms/pseries/eeh_driver.c index ef8e454..8f948a0 100644 --- a/arch/powerpc/platforms/pseries/eeh_driver.c +++ b/arch/powerpc/platforms/pseries/eeh_driver.c @@ -337,7 +337,7 @@ struct pci_dn * handle_eeh_events (struct eeh_event *event) location = location ? location : "unknown"; printk(KERN_ERR "EEH: Error: Cannot find partition endpoint " "for location=%s pci addr=%s\n", - location, pci_name(event->dev)); + location, eeh_pci_name(event->dev)); return NULL; } @@ -368,7 +368,7 @@ struct pci_dn * handle_eeh_events (struct eeh_event *event) pci_str = pci_name (frozen_pdn->pcidev); drv_str = pcid_name (frozen_pdn->pcidev); } else { - pci_str = pci_name (event->dev); + pci_str = eeh_pci_name (event->dev); drv_str = pcid_name (event->dev); } diff --git a/arch/powerpc/platforms/pseries/eeh_event.c b/arch/powerpc/platforms/pseries/eeh_event.c index ddb80f5..ec5df8f 100644 --- a/arch/powerpc/platforms/pseries/eeh_event.c +++ b/arch/powerpc/platforms/pseries/eeh_event.c @@ -80,7 +80,7 @@ static int eeh_event_handler(void * dummy) eeh_mark_slot(event->dn, EEH_MODE_RECOVERING); printk(KERN_INFO "EEH: Detected PCI bus error on device %s\n", - pci_name(event->dev)); + eeh_pci_name(event->dev)); pdn = handle_eeh_events(event); ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] eeh: Fixing a bug when pci structure is null 2010-02-02 17:46 ` [PATCH] eeh: Fixing a bug when pci structure is null Breno Leitao @ 2010-02-02 18:05 ` Wolfram Sang 2010-02-03 15:56 ` Breno Leitao 0 siblings, 1 reply; 8+ messages in thread From: Wolfram Sang @ 2010-02-02 18:05 UTC (permalink / raw) To: Breno Leitao; +Cc: Linas Vepstas, linuxppc-dev [-- Attachment #1: Type: text/plain, Size: 5051 bytes --] On Tue, Feb 02, 2010 at 03:46:28PM -0200, Breno Leitao wrote: > During a EEH recover, the pci_dev structure can be null, mainly if an > eeh event is detected during cpi config operation. In this case, the > pci_dev will not be known (and will be null) and the kernel will crash > with the following message: > > Unable to handle kernel paging request for data at address 0x000000a0 > Faulting instruction address: 0xc00000000006b8b4 > Oops: Kernel access of bad area, sig: 11 [#1] > > NIP [c00000000006b8b4] .eeh_event_handler+0x10c/0x1a0 > LR [c00000000006b8a8] .eeh_event_handler+0x100/0x1a0 > Call Trace: > [c0000003a80dff00] [c00000000006b8a8] .eeh_event_handler+0x100/0x1a0 > [c0000003a80dff90] [c000000000031f1c] .kernel_thread+0x54/0x70 > > The bug occurs because pci_name() tries to access a null pointer. > This patch just guarantee that pci_name() is not called on Null pointers. > > Signed-off-by: Breno Leitao <leitao@linux.vnet.ibm.com> > Signed-off-by: Linas Vepstas <linasvepstas@gmail.com> > --- > arch/powerpc/include/asm/ppc-pci.h | 7 +++++++ > arch/powerpc/platforms/pseries/eeh.c | 4 ++-- > arch/powerpc/platforms/pseries/eeh_driver.c | 4 ++-- > arch/powerpc/platforms/pseries/eeh_event.c | 2 +- > 4 files changed, 12 insertions(+), 5 deletions(-) > > diff --git a/arch/powerpc/include/asm/ppc-pci.h b/arch/powerpc/include/asm/ppc-pci.h > index 2828f9d..724dbe2 100644 > --- a/arch/powerpc/include/asm/ppc-pci.h > +++ b/arch/powerpc/include/asm/ppc-pci.h > @@ -137,6 +137,13 @@ struct device_node * find_device_pe(struct device_node *dn); > void eeh_sysfs_add_device(struct pci_dev *pdev); > void eeh_sysfs_remove_device(struct pci_dev *pdev); > > +static inline const char *eeh_pci_name(struct pci_dev *pdev) > +{ > + if (NULL==pdev) > + return "<null>"; > + return pci_name(pdev); What about: return pdev ? pci_name(pdev) : "<null>"; > +} > + > #endif /* CONFIG_EEH */ > > #else /* CONFIG_PCI */ > diff --git a/arch/powerpc/platforms/pseries/eeh.c b/arch/powerpc/platforms/pseries/eeh.c > index ccd8dd0..f9360fe 100644 > --- a/arch/powerpc/platforms/pseries/eeh.c > +++ b/arch/powerpc/platforms/pseries/eeh.c > @@ -491,7 +491,7 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev) > pdn->eeh_mode & EEH_MODE_NOCHECK) { > ignored_check++; > pr_debug("EEH: Ignored check (%x) for %s %s\n", > - pdn->eeh_mode, pci_name (dev), dn->full_name); > + pdn->eeh_mode, eeh_pci_name (dev), dn->full_name); No space after function name, please. > return 0; > } > > @@ -515,7 +515,7 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev) > printk (KERN_ERR "EEH: %d reads ignored for recovering device at " > "location=%s driver=%s pci addr=%s\n", > pdn->eeh_check_count, location, > - dev->driver->name, pci_name(dev)); > + dev->driver->name, eeh_pci_name(dev)); ditto > printk (KERN_ERR "EEH: Might be infinite loop in %s driver\n", > dev->driver->name); > dump_stack(); > diff --git a/arch/powerpc/platforms/pseries/eeh_driver.c b/arch/powerpc/platforms/pseries/eeh_driver.c > index ef8e454..8f948a0 100644 > --- a/arch/powerpc/platforms/pseries/eeh_driver.c > +++ b/arch/powerpc/platforms/pseries/eeh_driver.c > @@ -337,7 +337,7 @@ struct pci_dn * handle_eeh_events (struct eeh_event *event) > location = location ? location : "unknown"; > printk(KERN_ERR "EEH: Error: Cannot find partition endpoint " > "for location=%s pci addr=%s\n", > - location, pci_name(event->dev)); > + location, eeh_pci_name(event->dev)); > return NULL; > } > > @@ -368,7 +368,7 @@ struct pci_dn * handle_eeh_events (struct eeh_event *event) > pci_str = pci_name (frozen_pdn->pcidev); > drv_str = pcid_name (frozen_pdn->pcidev); > } else { > - pci_str = pci_name (event->dev); > + pci_str = eeh_pci_name (event->dev); ditto > drv_str = pcid_name (event->dev); > } > > diff --git a/arch/powerpc/platforms/pseries/eeh_event.c b/arch/powerpc/platforms/pseries/eeh_event.c > index ddb80f5..ec5df8f 100644 > --- a/arch/powerpc/platforms/pseries/eeh_event.c > +++ b/arch/powerpc/platforms/pseries/eeh_event.c > @@ -80,7 +80,7 @@ static int eeh_event_handler(void * dummy) > eeh_mark_slot(event->dn, EEH_MODE_RECOVERING); > > printk(KERN_INFO "EEH: Detected PCI bus error on device %s\n", > - pci_name(event->dev)); > + eeh_pci_name(event->dev)); > > pdn = handle_eeh_events(event); > _______________________________________________ > Linuxppc-dev mailing list > Linuxppc-dev@lists.ozlabs.org > https://lists.ozlabs.org/listinfo/linuxppc-dev -- Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 197 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] eeh: Fixing a bug when pci structure is null 2010-02-02 18:05 ` Wolfram Sang @ 2010-02-03 15:56 ` Breno Leitao 2010-02-19 16:43 ` Breno Leitao 0 siblings, 1 reply; 8+ messages in thread From: Breno Leitao @ 2010-02-03 15:56 UTC (permalink / raw) To: Wolfram Sang; +Cc: Linas Vepstas, linuxppc-dev During a EEH recover, the pci_dev structure can be null, mainly if an eeh event is detected during cpi config operation. In this case, the pci_dev will not be known (and will be null) the kernel will crash with the following message: Unable to handle kernel paging request for data at address 0x000000a0 Faulting instruction address: 0xc00000000006b8b4 Oops: Kernel access of bad area, sig: 11 [#1] NIP [c00000000006b8b4] .eeh_event_handler+0x10c/0x1a0 LR [c00000000006b8a8] .eeh_event_handler+0x100/0x1a0 Call Trace: [c0000003a80dff00] [c00000000006b8a8] .eeh_event_handler+0x100/0x1a0 [c0000003a80dff90] [c000000000031f1c] .kernel_thread+0x54/0x70 The bug occurs because pci_name() tries to access a null pointer. This patch just guarantee that pci_name() is not called on Null pointers. Signed-off-by: Breno Leitao <leitao@linux.vnet.ibm.com> Signed-off-by: Linas Vepstas <linasvepstas@gmail.com> --- arch/powerpc/include/asm/ppc-pci.h | 5 +++++ arch/powerpc/platforms/pseries/eeh.c | 4 ++-- arch/powerpc/platforms/pseries/eeh_driver.c | 4 ++-- arch/powerpc/platforms/pseries/eeh_event.c | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/include/asm/ppc-pci.h b/arch/powerpc/include/asm/ppc-pci.h index 2828f9d..42fdff0 100644 --- a/arch/powerpc/include/asm/ppc-pci.h +++ b/arch/powerpc/include/asm/ppc-pci.h @@ -137,6 +137,11 @@ struct device_node * find_device_pe(struct device_node *dn); void eeh_sysfs_add_device(struct pci_dev *pdev); void eeh_sysfs_remove_device(struct pci_dev *pdev); +static inline const char *eeh_pci_name(struct pci_dev *pdev) +{ + return pdev ? pci_name(pdev) : "<null>"; +} + #endif /* CONFIG_EEH */ #else /* CONFIG_PCI */ diff --git a/arch/powerpc/platforms/pseries/eeh.c b/arch/powerpc/platforms/pseries/eeh.c index ccd8dd0..3304f32 100644 --- a/arch/powerpc/platforms/pseries/eeh.c +++ b/arch/powerpc/platforms/pseries/eeh.c @@ -491,7 +491,7 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev) pdn->eeh_mode & EEH_MODE_NOCHECK) { ignored_check++; pr_debug("EEH: Ignored check (%x) for %s %s\n", - pdn->eeh_mode, pci_name (dev), dn->full_name); + pdn->eeh_mode, eeh_pci_name(dev), dn->full_name); return 0; } @@ -515,7 +515,7 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev) printk (KERN_ERR "EEH: %d reads ignored for recovering device at " "location=%s driver=%s pci addr=%s\n", pdn->eeh_check_count, location, - dev->driver->name, pci_name(dev)); + dev->driver->name, eeh_pci_name(dev)); printk (KERN_ERR "EEH: Might be infinite loop in %s driver\n", dev->driver->name); dump_stack(); diff --git a/arch/powerpc/platforms/pseries/eeh_driver.c b/arch/powerpc/platforms/pseries/eeh_driver.c index ef8e454..977d87d 100644 --- a/arch/powerpc/platforms/pseries/eeh_driver.c +++ b/arch/powerpc/platforms/pseries/eeh_driver.c @@ -337,7 +337,7 @@ struct pci_dn * handle_eeh_events (struct eeh_event *event) location = location ? location : "unknown"; printk(KERN_ERR "EEH: Error: Cannot find partition endpoint " "for location=%s pci addr=%s\n", - location, pci_name(event->dev)); + location, eeh_pci_name(event->dev)); return NULL; } @@ -368,7 +368,7 @@ struct pci_dn * handle_eeh_events (struct eeh_event *event) pci_str = pci_name (frozen_pdn->pcidev); drv_str = pcid_name (frozen_pdn->pcidev); } else { - pci_str = pci_name (event->dev); + pci_str = eeh_pci_name(event->dev); drv_str = pcid_name (event->dev); } diff --git a/arch/powerpc/platforms/pseries/eeh_event.c b/arch/powerpc/platforms/pseries/eeh_event.c index ddb80f5..ec5df8f 100644 --- a/arch/powerpc/platforms/pseries/eeh_event.c +++ b/arch/powerpc/platforms/pseries/eeh_event.c @@ -80,7 +80,7 @@ static int eeh_event_handler(void * dummy) eeh_mark_slot(event->dn, EEH_MODE_RECOVERING); printk(KERN_INFO "EEH: Detected PCI bus error on device %s\n", - pci_name(event->dev)); + eeh_pci_name(event->dev)); pdn = handle_eeh_events(event); -- 1.6.0.2 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] eeh: Fixing a bug when pci structure is null 2010-02-03 15:56 ` Breno Leitao @ 2010-02-19 16:43 ` Breno Leitao 2010-02-19 17:05 ` Linas Vepstas 2010-02-19 21:54 ` Benjamin Herrenschmidt 0 siblings, 2 replies; 8+ messages in thread From: Breno Leitao @ 2010-02-19 16:43 UTC (permalink / raw) To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, Linas Vepstas Hi Ben, I'd like to ask about this patch ? Should I re-submit ? Thanks, Breno Leitao wrote: > During a EEH recover, the pci_dev structure can be null, mainly if an > eeh event is detected during cpi config operation. In this case, the > pci_dev will not be known (and will be null) the kernel will crash > with the following message: ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] eeh: Fixing a bug when pci structure is null 2010-02-19 16:43 ` Breno Leitao @ 2010-02-19 17:05 ` Linas Vepstas 2010-02-19 21:55 ` Benjamin Herrenschmidt 2010-02-19 21:54 ` Benjamin Herrenschmidt 1 sibling, 1 reply; 8+ messages in thread From: Linas Vepstas @ 2010-02-19 17:05 UTC (permalink / raw) To: Breno Leitao, Paul Mackerras; +Cc: linuxppc-dev Hi Paul, Breno, Some confusion -- I've been out of the loop for a while -- I assume its still Paul who is pushing these patches upstream, and not Ben? So Breno, maybe you should resend the patch to Paul? --linas On 19 February 2010 10:43, Breno Leitao <leitao@linux.vnet.ibm.com> wrote: > Hi Ben, > > I'd like to ask about this patch ? Should I re-submit ? > > Thanks, > > Breno Leitao wrote: >> During a EEH recover, the pci_dev structure can be null, mainly if an >> eeh event is detected during cpi config operation. In this case, the >> pci_dev will not be known (and will be null) the kernel will crash >> with the following message: > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] eeh: Fixing a bug when pci structure is null 2010-02-19 17:05 ` Linas Vepstas @ 2010-02-19 21:55 ` Benjamin Herrenschmidt 0 siblings, 0 replies; 8+ messages in thread From: Benjamin Herrenschmidt @ 2010-02-19 21:55 UTC (permalink / raw) To: linasvepstas; +Cc: linuxppc-dev, Paul Mackerras, Breno Leitao On Fri, 2010-02-19 at 11:05 -0600, Linas Vepstas wrote: > > Some confusion -- I've been out of the loop for a while -- I assume > its still Paul who is pushing > these patches upstream, and not Ben? So Breno, maybe you should > resend the patch to Paul? No, it's me. Cheers, Ben. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] eeh: Fixing a bug when pci structure is null 2010-02-19 16:43 ` Breno Leitao 2010-02-19 17:05 ` Linas Vepstas @ 2010-02-19 21:54 ` Benjamin Herrenschmidt 2010-02-24 22:13 ` Mike Mason 1 sibling, 1 reply; 8+ messages in thread From: Benjamin Herrenschmidt @ 2010-02-19 21:54 UTC (permalink / raw) To: Breno Leitao; +Cc: linuxppc-dev, Linas Vepstas On Fri, 2010-02-19 at 14:43 -0200, Breno Leitao wrote: > Hi Ben, > > I'd like to ask about this patch ? Should I re-submit ? > > Thanks, > > Breno Leitao wrote: > > During a EEH recover, the pci_dev structure can be null, mainly if an > > eeh event is detected during cpi config operation. In this case, the > > pci_dev will not be known (and will be null) the kernel will crash > > with the following message: It should be in -next, can you dbl check ? Cheers, Ben. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] eeh: Fixing a bug when pci structure is null 2010-02-19 21:54 ` Benjamin Herrenschmidt @ 2010-02-24 22:13 ` Mike Mason 0 siblings, 0 replies; 8+ messages in thread From: Mike Mason @ 2010-02-24 22:13 UTC (permalink / raw) To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, Linas Vepstas, Breno Leitao On 2/19/2010 1:54 PM, Benjamin Herrenschmidt wrote: > On Fri, 2010-02-19 at 14:43 -0200, Breno Leitao wrote: >> Hi Ben, >> >> I'd like to ask about this patch ? Should I re-submit ? >> >> Thanks, >> >> Breno Leitao wrote: >>> During a EEH recover, the pci_dev structure can be null, mainly if an >>> eeh event is detected during cpi config operation. In this case, the >>> pci_dev will not be known (and will be null) the kernel will crash >>> with the following message: > > It should be in -next, can you dbl check ? I just confirmed the patch is in the -next tree. Mike > > Cheers, > Ben. > > > _______________________________________________ > Linuxppc-dev mailing list > Linuxppc-dev@lists.ozlabs.org > https://lists.ozlabs.org/listinfo/linuxppc-dev ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-02-24 22:14 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <1264789719-15591-1-git-send-email-leitao@linux.vnet.ibm.com> 2010-02-02 17:46 ` [PATCH] eeh: Fixing a bug when pci structure is null Breno Leitao 2010-02-02 18:05 ` Wolfram Sang 2010-02-03 15:56 ` Breno Leitao 2010-02-19 16:43 ` Breno Leitao 2010-02-19 17:05 ` Linas Vepstas 2010-02-19 21:55 ` Benjamin Herrenschmidt 2010-02-19 21:54 ` Benjamin Herrenschmidt 2010-02-24 22:13 ` Mike Mason
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).