public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frederik Deweerdt <frederik.deweerdt@xprog.eu>
To: Sven-Thorsten Dietrich <sdietrich@novell.com>
Cc: Frederik Deweerdt <frederik.deweerdt@xprog.eu>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-rt-users <linux-rt-users@vger.kernel.org>
Subject: Re: [PATCH][UHCI-DEBUG] Don't kmalloc with BKL held
Date: Tue, 6 Oct 2009 07:51:41 +0000	[thread overview]
Message-ID: <20091006075141.GA6650@gambetta> (raw)
In-Reply-To: <1254573359.11691.0.camel@sven.thebigcorporation.com>

On Sat, Oct 03, 2009 at 05:35:59AM -0700, Sven-Thorsten Dietrich wrote:
> On Fri, 2009-10-02 at 09:20 +0000, Frederik Deweerdt wrote:
> > Hi Sven-Thorsten,
> > 
> > On Fri, Oct 02, 2009 at 11:12:24AM +0200, Sven-Thorsten Dietrich wrote:
> > > Subject: Don't kmalloc with BKL held.
> > > From: Sven-Thorsten Dietrich <sdietrich@suse.de>
> > > 
> > > I'm eyeballing this file for complete removal of lock_kernel but 
> > > at first glance, we definitely don't need BKL to kmalloc(). 
> > You need to move the unlock_kernel() above the out: label too.
> > 
> 
> How about this ?
Yes, looks good to me.

> 
> Subject: Don't kmalloc with BKL held.
> From: Sven-Thorsten Dietrich sdietrich@suse.de Sat Oct 3 01:27:27 2009 -0700
> Date: Sat Oct 3 01:27:27 2009 -0700:
> Git: 4f62eb81e827eb857129101e49757d84ac9ee7eb
> 
> We don't need BKL to kmalloc
> 
> diff --git a/drivers/usb/host/uhci-debug.c b/drivers/usb/host/uhci-debug.c
> index e52b954..3fd5602 100644
> --- a/drivers/usb/host/uhci-debug.c
> +++ b/drivers/usb/host/uhci-debug.c
> @@ -494,32 +494,30 @@ static int uhci_debug_open(struct inode *inode, struct file *file)
>  {
>  	struct uhci_hcd *uhci = inode->i_private;
>  	struct uhci_debug *up;
> -	int ret = -ENOMEM;
>  	unsigned long flags;
>  
> -	lock_kernel();
>  	up = kmalloc(sizeof(*up), GFP_KERNEL);
>  	if (!up)
> -		goto out;
> +		return -ENOMEM;
>  
>  	up->data = kmalloc(MAX_OUTPUT, GFP_KERNEL);
>  	if (!up->data) {
>  		kfree(up);
> -		goto out;
> +		return -ENOMEM;
>  	}
>  
>  	up->size = 0;
> +
> +	lock_kernel();
>  	spin_lock_irqsave(&uhci->lock, flags);
>  	if (uhci->is_initialized)
>  		up->size = uhci_sprint_schedule(uhci, up->data, MAX_OUTPUT);
>  	spin_unlock_irqrestore(&uhci->lock, flags);
>  
>  	file->private_data = up;
> -
> -	ret = 0;
> -out:
>  	unlock_kernel();
> -	return ret;
> +
> +	return 0;
>  }
>  
>  static loff_t uhci_debug_lseek(struct file *file, loff_t off, int whence)
> 
> 

  reply	other threads:[~2009-10-06  7:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-02  9:12 [PATCH][UHCI-DEBUG] Don't kmalloc with BKL held Sven-Thorsten Dietrich
2009-10-02  9:20 ` Frederik Deweerdt
2009-10-03 12:35   ` Sven-Thorsten Dietrich
2009-10-06  7:51     ` Frederik Deweerdt [this message]
2009-10-06 10:09     ` Thomas Gleixner
2009-10-02 12:01 ` Oliver Neukum

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=20091006075141.GA6650@gambetta \
    --to=frederik.deweerdt@xprog.eu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=sdietrich@novell.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox