All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Jesper Juhl <jesper.juhl@gmail.com>
Cc: Eric Moore <Eric.Moore@lsi.com>,
	DL-MPTFusionLinux@lsi.com,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	support@lsi.com, mpt_linux_developer@lsi.com,
	linux-scsi@vger.kernel.org,
	James Bottomley <James.Bottomley@steeleye.com>
Subject: Re: [PATCH] Fix two potential mem leaks in MPT Fusion (mpt_attach())
Date: Wed, 1 Aug 2007 17:26:53 -0700	[thread overview]
Message-ID: <20070801172653.1fd44e99.akpm@linux-foundation.org> (raw)
In-Reply-To: <200708020155.33690.jesper.juhl@gmail.com>

On Thu, 2 Aug 2007 01:55:33 +0200
Jesper Juhl <jesper.juhl@gmail.com> wrote:

> Greetings & Salutations,
> 
> The Coverity checker spotted two potential memory leaks in 
> drivers/message/fusion/mptbase.c::mpt_attach().
> 
> There are two returns that may leak the storage allocated for 
> 'ioc' (sizeof(MPT_ADAPTER) bytes).
> A simple fix would be to simply add two kfree() calls before 
> the return statements, but a better fix (that this patch 
> implements) is to reorder the code so that if we hit the first 
> return condition we don't have to do the allocation at all and 
> then just add a kfree() call for the second case.
> 
> Please consider applying.  Patch has been compile tested only.
> 
> 

umm,

> ---
> 
>  drivers/message/fusion/mptbase.c |   13 +++++++------
>  1 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
> index e866dac..f9bb705 100644
> --- a/drivers/message/fusion/mptbase.c
> +++ b/drivers/message/fusion/mptbase.c
> @@ -1393,18 +1393,18 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
>  	struct proc_dir_entry *dent, *ent;
>  #endif
>  
> +	if (mpt_debug_level)
> +		printk(KERN_INFO MYNAM ": mpt_debug_level=%xh\n", mpt_debug_level);
> +
> +	if (pci_enable_device(pdev))
> +		return r;
> +
>  	ioc = kzalloc(sizeof(MPT_ADAPTER), GFP_ATOMIC);

Why on earth is that using GFP_ATOMIC?  This function later goes on to
create procfs files and such things.




y'know, we could have a debug option which will spit warnings if someone
does a !__GFP_WAIT allocation while !in_atomic() (only works if
CONFIG_PREEMPT).  

But please, make it depend on !CONFIG_AKPM.  I shudder to think about all
the stuff it would pick up.



  reply	other threads:[~2007-08-02  0:27 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-01 23:55 [PATCH] Fix two potential mem leaks in MPT Fusion (mpt_attach()) Jesper Juhl
2007-08-02  0:26 ` Andrew Morton [this message]
2007-08-02  3:03   ` Matthew Wilcox
2007-08-02  5:13     ` Andrew Morton
2007-08-02  8:20   ` Jesper Juhl
2007-08-02 22:53     ` Jesper Juhl
2007-08-02 22:53       ` Jesper Juhl
2007-08-02 23:04       ` Andrew Morton
2007-08-02 23:04         ` Andrew Morton
2007-08-02 23:10         ` Jesper Juhl
2007-08-02 23:10           ` Jesper Juhl
2007-08-02 23:17           ` Andrew Morton
2007-08-02 23:17             ` Andrew Morton
2007-08-02 23:26             ` Jesper Juhl
2007-08-02 23:26               ` Jesper Juhl
2007-08-03  0:47               ` Christoph Lameter
2007-08-03  0:47                 ` Christoph Lameter

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=20070801172653.1fd44e99.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=DL-MPTFusionLinux@lsi.com \
    --cc=Eric.Moore@lsi.com \
    --cc=James.Bottomley@steeleye.com \
    --cc=jesper.juhl@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mpt_linux_developer@lsi.com \
    --cc=support@lsi.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.