linux-um archives
 help / color / mirror / Atom feed
From: BlaisorBlade <blaisorblade_spam@yahoo.it>
To: Jeff Dike <jdike@addtoit.com>
Cc: user-mode-linux-devel@lists.sourceforge.net
Subject: [uml-devel] Re: [patch 1/1] Fix malloc-use-vmalloc
Date: Thu, 22 Jul 2004 17:55:45 +0200	[thread overview]
Message-ID: <200407221752.42186.blaisorblade_spam@yahoo.it> (raw)
In-Reply-To: <200407131757.i6DHvZGu003047@ccure.user-mode-linux.org>

Alle 19:57, martedì 13 luglio 2004, Jeff Dike ha scritto:

> This isn't exactly right.  In the case that a buffer was allocated by
> kmalloc (through malloc), but freed when the system is coming down, and
> kmalloc is no longer operating, then you just want to do nothing. It would
> be very bad to try to free it using libc free.
>
> So, what I did is this:
>
> 	if((addr >= uml_physmem) && (addr <= high_physmem)){
> 		if(CAN_KMALLOC())
> 			kfree(ptr);
> 	}
> 	else if((addr >= start_vm) && (addr <= end_vm)){
> 		if(CAN_KMALLOC())
> 			vfree(ptr);
> 	}
> 	else __real_free(ptr);

1) I think that the intervals don't include high_physmem and end_vm, so we 
should have addr < ... instead of addr <=.

2) Also, even worse, it seems ok until you read your comment. During the boot, 
if random values are in the vars (and it's so until kmalloc_ok is turned on) 
we can have malloc()ed memory thought of as kmalloc()ed or vmalloc()ed one, 
and then leaked.

3) Solution to 2): if I am right about thing #1, then it should be enough to 
set end_vm and high_physmem to 0 at startup (they are global vars, so it's 
already true), once there are the < instead of <=. And don't say in the 
comment that memory regions are not initialized.

Any comment? I need this to send the patch to Andrew Morton for 2.6-mm
-- 
Paolo Giarrusso, aka Blaisorblade
Linux registered user n. 292729




-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_idG21&alloc_id\x10040&opÌk
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

  reply	other threads:[~2004-07-22 18:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-04 10:56 [uml-devel] [patch 1/1] Fix malloc-use-vmalloc blaisorblade_spam
2004-07-13 17:57 ` [uml-devel] " Jeff Dike
2004-07-22 15:55   ` BlaisorBlade [this message]
2004-07-26 18:18     ` Jeff Dike

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=200407221752.42186.blaisorblade_spam@yahoo.it \
    --to=blaisorblade_spam@yahoo.it \
    --cc=jdike@addtoit.com \
    --cc=user-mode-linux-devel@lists.sourceforge.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