public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Martin Waitz <tali@admingilde.org>
To: Stelian Pop <stelian@popies.net>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] kfifo_alloc buffer
Date: Thu, 4 Nov 2004 18:06:32 +0100	[thread overview]
Message-ID: <20041104170632.GX3618@admingilde.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 1234 bytes --]

hi :)

kfifo_alloc tries to round up the buffer size to the next power of two.
But it accidently uses the original size when calling kfifo_init,
which will BUG.

Signed-off-by: Martin Waitz <tali@admingilde.org>

Index: kernel/kfifo.c
===================================================================
RCS file: /home/inf3/mnwaitz/src/linux-cvs/linux-2.5/kernel/kfifo.c,v
retrieving revision 1.2
diff -u -p -r1.2 kfifo.c
--- kernel/kfifo.c	19 Oct 2004 15:12:21 -0000	1.2
+++ kernel/kfifo.c	4 Nov 2004 17:00:34 -0000
@@ -66,7 +66,6 @@ EXPORT_SYMBOL(kfifo_init);
  */
 struct kfifo *kfifo_alloc(unsigned int size, int gfp_mask, spinlock_t *lock)
 {
-	unsigned int newsize;
 	unsigned char *buffer;
 	struct kfifo *ret;
 
@@ -74,13 +73,12 @@ struct kfifo *kfifo_alloc(unsigned int s
 	 * round up to the next power of 2, since our 'let the indices
 	 * wrap' tachnique works only in this case.
 	 */
-	newsize = size;
 	if (size & (size - 1)) {
 		BUG_ON(size > 0x80000000);
-		newsize = roundup_pow_of_two(size);
+		size = roundup_pow_of_two(size);
 	}
 
-	buffer = kmalloc(newsize, gfp_mask);
+	buffer = kmalloc(size, gfp_mask);
 	if (!buffer)
 		return ERR_PTR(-ENOMEM);
 

-- 
Martin Waitz

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

             reply	other threads:[~2004-11-04 17:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-04 17:06 Martin Waitz [this message]
2004-11-04 19:15 ` [PATCH] kfifo_alloc buffer Stelian Pop
2004-11-05  8:58   ` Martin Waitz

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=20041104170632.GX3618@admingilde.org \
    --to=tali@admingilde.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stelian@popies.net \
    /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