public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ben Hutchings <ben@decadent.org.uk>
To: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org,
	Linux-Arch <linux-arch@vger.kernel.org>,
	Thorsten Glaser <tg@mirbsd.de>,
	Debian kernel team <debian-kernel@lists.debian.org>,
	linux-m68k@vger.kernel.org, debian-68k@lists.debian.org
Subject: [PATCH 1/2] topology: Check for missing CPU devices
Date: Sun, 08 Jan 2012 20:48:34 +0000	[thread overview]
Message-ID: <1326055714.13595.309.camel@deadeye> (raw)

Commit ccbc60d3e19a1b6ae66ca0d89b3da02dde62088b ('topology: Provide
CPU topology in sysfs in !SMP configurations') causes a crash at boot
on a several architectures.  The topology sysfs code assumes that
there is a CPU device for each online CPU whereas some architectures
that do not support SMP or cpufreq do not register any CPU devices.
Check for this before trying to use a device.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 drivers/base/topology.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index ae989c5..4467c85 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -147,6 +147,8 @@ static int __cpuinit topology_add_dev(unsigned int cpu)
 {
 	struct device *dev = get_cpu_device(cpu);
 
+	if (!dev)
+		return -ENODEV;
 	return sysfs_create_group(&dev->kobj, &topology_attr_group);
 }
 
@@ -154,7 +156,8 @@ static void __cpuinit topology_remove_dev(unsigned int cpu)
 {
 	struct device *dev = get_cpu_device(cpu);
 
-	sysfs_remove_group(&dev->kobj, &topology_attr_group);
+	if (dev)
+		sysfs_remove_group(&dev->kobj, &topology_attr_group);
 }
 
 static int __cpuinit topology_cpu_callback(struct notifier_block *nfb,
-- 
1.7.8.2




             reply	other threads:[~2012-01-08 20:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-08 20:48 Ben Hutchings [this message]
2012-01-08 20:55 ` [PATCH 2/2] cpu: Register a generic CPU device on architectures that currently do not Ben Hutchings
2012-01-09 20:14   ` Geert Uytterhoeven
2012-01-09  0:18 ` [PATCH 1/2] topology: Check for missing CPU devices Linus Torvalds
2012-01-09  1:06   ` richard -rw- weinberger
2012-01-09  1:29     ` Linus Torvalds
2012-01-09  2:52       ` Ben Hutchings
2012-01-09 14:19         ` Richard Weinberger
2012-01-09 20:15     ` Geert Uytterhoeven
2012-01-09  2:47   ` Ben Hutchings
2012-01-09  2:56     ` Ben Hutchings
2012-01-09 20:23       ` Linus Torvalds
2012-01-09 20:13 ` Geert Uytterhoeven

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=1326055714.13595.309.camel@deadeye \
    --to=ben@decadent.org.uk \
    --cc=akpm@linux-foundation.org \
    --cc=debian-68k@lists.debian.org \
    --cc=debian-kernel@lists.debian.org \
    --cc=geert@linux-m68k.org \
    --cc=gregkh@suse.de \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@vger.kernel.org \
    --cc=tg@mirbsd.de \
    --cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox