All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org
Cc: johnrose@austin.ibm.com
Subject: [PATCH] PCI: fix release_pcibus_dev() crash
Date: Mon, 17 Jan 2005 14:01:53 -0800	[thread overview]
Message-ID: <11059993132086@kroah.com> (raw)
In-Reply-To: <11059993132995@kroah.com>

ChangeSet 1.2329.2.8, 2005/01/14 15:59:20-08:00, johnrose@austin.ibm.com

[PATCH] PCI: fix release_pcibus_dev() crash

During the course of a hotplug removal of a PCI bus, release_pcibus_dev()
attempts to remove attribute files from a kobject directory that no longer
exists.  This patch moves these calls to pci_remove_bus(), where they can work
as intended.

Signed-off-by: John Rose <johnrose@austin.ibm.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>


 drivers/pci/pci.h    |    2 ++
 drivers/pci/probe.c  |   10 +++-------
 drivers/pci/remove.c |   13 ++++++++-----
 3 files changed, 13 insertions(+), 12 deletions(-)


diff -Nru a/drivers/pci/pci.h b/drivers/pci/pci.h
--- a/drivers/pci/pci.h	2005-01-17 13:55:30 -08:00
+++ b/drivers/pci/pci.h	2005-01-17 13:55:30 -08:00
@@ -59,12 +59,14 @@
 extern int pci_visit_dev(struct pci_visit *fn,
 			 struct pci_dev_wrapped *wrapped_dev,
 			 struct pci_bus_wrapped *wrapped_parent);
+extern void pci_remove_legacy_files(struct pci_bus *bus);
 
 /* Lock for read/write access to pci device and bus lists */
 extern spinlock_t pci_bus_lock;
 
 extern int pcie_mch_quirk;
 extern struct device_attribute pci_dev_attrs[];
+extern struct class_device_attribute class_device_attr_cpuaffinity;
 
 /**
  * pci_match_one_device - Tell if a PCI device structure has a matching
diff -Nru a/drivers/pci/probe.c b/drivers/pci/probe.c
--- a/drivers/pci/probe.c	2005-01-17 13:55:30 -08:00
+++ b/drivers/pci/probe.c	2005-01-17 13:55:30 -08:00
@@ -62,7 +62,7 @@
 	}
 }
 
-static void pci_remove_legacy_files(struct pci_bus *b)
+void pci_remove_legacy_files(struct pci_bus *b)
 {
 	class_device_remove_bin_file(&b->class_dev, b->legacy_io);
 	class_device_remove_bin_file(&b->class_dev, b->legacy_mem);
@@ -70,7 +70,7 @@
 }
 #else /* !HAVE_PCI_LEGACY */
 static inline void pci_create_legacy_files(struct pci_bus *bus) { return; }
-static inline void pci_remove_legacy_files(struct pci_bus *bus) { return; }
+void pci_remove_legacy_files(struct pci_bus *bus) { return; }
 #endif /* HAVE_PCI_LEGACY */
 
 /*
@@ -86,7 +86,7 @@
 		buf[ret++] = '\n';
 	return ret;
 }
-static CLASS_DEVICE_ATTR(cpuaffinity, S_IRUGO, pci_bus_show_cpuaffinity, NULL);
+CLASS_DEVICE_ATTR(cpuaffinity, S_IRUGO, pci_bus_show_cpuaffinity, NULL);
 
 /*
  * PCI Bus Class
@@ -95,10 +95,6 @@
 {
 	struct pci_bus *pci_bus = to_pci_bus(class_dev);
 
-	pci_remove_legacy_files(pci_bus);
-	class_device_remove_file(&pci_bus->class_dev,
-				 &class_device_attr_cpuaffinity);
-	sysfs_remove_link(&pci_bus->class_dev.kobj, "bridge");
 	if (pci_bus->bridge)
 		put_device(pci_bus->bridge);
 	kfree(pci_bus);
diff -Nru a/drivers/pci/remove.c b/drivers/pci/remove.c
--- a/drivers/pci/remove.c	2005-01-17 13:55:30 -08:00
+++ b/drivers/pci/remove.c	2005-01-17 13:55:30 -08:00
@@ -61,15 +61,18 @@
 }
 EXPORT_SYMBOL(pci_remove_device_safe);
 
-void pci_remove_bus(struct pci_bus *b)
+void pci_remove_bus(struct pci_bus *pci_bus)
 {
-	pci_proc_detach_bus(b);
+	pci_proc_detach_bus(pci_bus);
 
 	spin_lock(&pci_bus_lock);
-	list_del(&b->node);
+	list_del(&pci_bus->node);
 	spin_unlock(&pci_bus_lock);
-
-	class_device_unregister(&b->class_dev);
+	pci_remove_legacy_files(pci_bus);
+	class_device_remove_file(&pci_bus->class_dev,
+		&class_device_attr_cpuaffinity);
+	sysfs_remove_link(&pci_bus->class_dev.kobj, "bridge");
+	class_device_unregister(&pci_bus->class_dev);
 }
 EXPORT_SYMBOL(pci_remove_bus);
 


  reply	other threads:[~2005-01-17 22:43 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-17 22:01 [BK PATCH] PCI fixes and PCI Express drivers for 2.6.11-rc1 Greg KH
2005-01-17 22:01 ` [PATCH] PCI: add PCI Express Port Bus Driver subsystem Greg KH
2005-01-17 22:01   ` [PATCH] PCI: use modern format for PCI addresses Greg KH
2005-01-17 22:01     ` [PATCH] PCI: pci_ids.h correction for Intel ICH7 - 2.6.10-bk13 Greg KH
2005-01-17 22:01       ` [PATCH] PCI: Clean up printks in msi.c Greg KH
2005-01-17 22:01         ` [PATCH] PCI: rom.c cleanups Greg KH
2005-01-17 22:01           ` [PATCH] PCI: Downgrade printk that complains about unsupported PCI PM caps Greg KH
2005-01-17 22:01             ` [PATCH] PCI: Lock initializer cleanup - batch 4 Greg KH
2005-01-17 22:01               ` Greg KH [this message]
2005-01-17 22:01                 ` PCI: move pcie build into the drivers/pci/ subdirectory Greg KH
2005-01-17 23:49   ` [PATCH] PCI: add PCI Express Port Bus Driver subsystem Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11059993132086@kroah.com \
    --to=greg@kroah.com \
    --cc=johnrose@austin.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.