mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joachim Weller <joachim_weller@hsgmed.com>
To: linux-kernel@vger.kernel.org
Cc: JoachimWeller@web.de
Subject: BUG: cat /proc/partitions endless loop
Date: Fri, 28 Sep 2001 15:15:51 +0200	[thread overview]
Message-ID: <200109281315.f8SDFpA01669@bmdipc2c.germany.agilent.com> (raw)

After upgrading from 2.4.9 to 2.4.10, I discovered that
a "cat /proc/partitions" resulted in an infinite  repetition
of the partition list.
This resulted in a complete hang of SuSE's sys admin tool yast.
A more detailed report was sent to Jens Axboe (axboe@suse.de)

The affected machine is a dual pentium pro:
 Linux version 2.4.10 (root@bmdipc2c) (gcc version 2.95.3 20010315 (SuSE)) #1 
SMP Fri Sep 28 13:10:18 CEST 2001

 I traced the problem down to drivers/block/genhd.c, 
where the function get_partition_list() outer loop does not 
terminate due to the last element in the structured list starting 
with gendisk_head is not initialized to NULL, by whatever reason.
My fix does not cure the pointered endless loop, but prevents
from looping when stepping thru the pointered list.
--------------------------------------------------------------------------------------
diff -u --recursive --new-file 2.4.10/linux/drivers/block/genhd.c 
linux/drivers/block/genhd.c
--- 2.4.10/linux/drivers/block/genhd.c  Sun Sep  9 21:00:55 2001
+++ linux/drivers/block/genhd.c Fri Sep 28 14:45:13 2001
@@ -14,6 +14,15 @@
  * TODO:  rip out the remaining init crap from this file  --hch
  */

+/*
+ * Change: Blocked potential endless loop within get_partition_list()
+ *         which occured for "cat /proc/partitions"
+ *         because gendisk_head->next is not initialized correctly to NULL
+ *         before add_gendisk() is called the first time.
+ *         Joachim Weller 28sep2001 (JoachimWeller@web.de)
+ *
+ */
+
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/fs.h>
@@ -115,7 +124,7 @@

        len = sprintf(page, "major minor  #blocks  name\n\n");
        read_lock(&gendisk_lock);
-       for (gp = gendisk_head; gp; gp = gp->next) {
+       for (gp = gendisk_head; gp; gp = (gp->next!=gendisk_head ?  gp->next 
: NULL)) {
                for (n = 0; n < (gp->nr_real << gp->minor_shift); n++) {
                        if (gp->part[n].nr_sects == 0)
                                continue;

--------------------------------------------------------------------------------------

-- 
Joachim Weller

Philips Medizinsysteme Boeblingen GmbH		Mail:  joachim_weller@hsgmed.com
Cardiac and Monitoring Systems (CMS)		Phone: {+49|0}-7031-463-1891
New Product Engineering				Fax:   {+49|0}-7031-463-2112

Hewlett-Packard Str. 2,	D 71034 Boeblingen	-GERMANY-


             reply	other threads:[~2001-09-28 13:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-28 13:15 Joachim Weller [this message]
2001-09-28 13:39 ` Christoph Hellwig
2001-09-28 14:48 Joachim Weller
2001-09-28 15:00 ` Christoph Hellwig
2001-09-28 15:22   ` Joachim Weller

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=200109281315.f8SDFpA01669@bmdipc2c.germany.agilent.com \
    --to=joachim_weller@hsgmed.com \
    --cc=JoachimWeller@web.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®