public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Stephen C. Biggs" <s.biggs@softier.com>
To: linux-kernel@vger.kernel.org
Subject: Bug in kernel code?
Date: Tue, 27 Aug 2002 17:25:17 -0700	[thread overview]
Message-ID: <3D6BB5FD.16049.2F324B@localhost> (raw)

I posted this to the newsgroup news:linux-kernel but got no response... 
I'll try here.

While going thru the kernel code for 2.4.17 (uClinux patch) I noticed a 
problem with functions in 3 files:
dcache_init in fs/dcache.c, inode_init in fs/inode.c and in mnt_init in 
fs/namespace.c

At least on my Redhat 7.3 2.4.18-10 source, in the function

static void __init dcache_init(unsigned long mempages)
{
	struct list_head *d;
	unsigned long order;
	unsigned int nr_hash;
	int i;

	/* 
	 * A constructor could be added for stable state like the lists,
	 * but it is probably not worth it because of the cache nature
	 * of the dcache. 
	 * If fragmentation is too bad then the SLAB_HWCACHE_ALIGN
	 * flag could be removed here, to hint to the allocator that
	 * it should not try to get multiple page regions.  
	 */
	dentry_cache = kmem_cache_create("dentry_cache",
					 sizeof(struct dentry),
					 0,
					 SLAB_HWCACHE_ALIGN,
					 NULL, NULL);
	if (!dentry_cache)
		panic("Cannot create dentry cache");

#if PAGE_SHIFT < 13
	mempages >>= (13 - PAGE_SHIFT);
#endif
	mempages *= sizeof(struct list_head);
	for (order = 0; ((1UL << order) << PAGE_SHIFT) < mempages; order++)
		;

	do {
		u32 tmp;

		nr_hash = (1UL << order) * PAGE_SIZE /
			sizeof(struct list_head);
		d_hash_mask = (nr_hash - 1);

		tmp = nr_hash;
		d_hash_shift = 0;
		while ((tmp >>= 1UL) != 0UL)
			d_hash_shift++;

		dentry_hashtable = (struct list_head *)
			__get_free_pages(GFP_ATOMIC, order);
	} while (dentry_hashtable == NULL && --order >= 0);


........... Notice the --order >=0 in the do while test... since order 
is declared as an unsigned long, this test is a pointless comparison and 
never fails, causing an infinite loop if the hashtable is empty.  

My fix to this is to change the test to have
while (dentry_hashtable == NULL && order-- != 0);

Could someone check me on this?



             reply	other threads:[~2002-08-28  0:21 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-28  0:25 Stephen C. Biggs [this message]
     [not found] <3D6BB5C3.16057.2E515C@localhost>
     [not found] ` <20020827.172304.22017977.davem@redhat.com>
2002-08-28  0:32   ` Bug in kernel code? Stephen C. Biggs
2002-08-28  0:29     ` David S. Miller
2002-08-28  0:40       ` Stephen C. Biggs
2002-08-28  0:42         ` David S. Miller
2002-08-28  1:09           ` Stephen C. Biggs
2002-08-28  1:09             ` David S. Miller
2002-08-28  1:24               ` Stephen C. Biggs
2002-08-28  1:23                 ` David S. Miller
2002-08-28  2:42                   ` Stephen C. Biggs
2002-08-28  3:39                     ` David S. Miller
2002-08-28  3:57                       ` Luca Barbieri
2002-08-28  3:58                         ` David S. Miller
2002-08-28  4:10                           ` Luca Barbieri
2002-08-28  4:07                             ` David S. Miller
2002-08-28  4:29                               ` Luca Barbieri
2002-08-28  4:29                       ` Stephen Biggs
2002-08-28  4:26                         ` David S. Miller
2002-08-28 21:54                           ` H. Peter Anvin
2002-08-28  0:54   ` Stephen C. Biggs

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=3D6BB5FD.16049.2F324B@localhost \
    --to=s.biggs@softier.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox