2009-07-09 10:40:20

by Sergey Senozhatsky

[permalink] [raw]
Subject: kmemeleak BUG: lock held when returning to user space!

Hello.

kernel: [ 149.507103] ================================================
kernel: [ 149.507113] [ BUG: lock held when returning to user space! ]
kernel: [ 149.507119] ------------------------------------------------
kernel: [ 149.507127] cat/3279 is leaving the kernel with locks still held!
kernel: [ 149.507135] 1 lock held by cat/3279:
kernel: [ 149.507141] #0: (scan_mutex){+.+.+.}, at: [<c110707c>] kmemleak_open+0x4c/0x80

problem is here:
static int kmemleak_open(struct inode *inode, struct file *file)
{
int ret = 0;

if (!atomic_read(&kmemleak_enabled))
return -EBUSY;

ret = mutex_lock_interruptible(&scan_mutex);
if (ret < 0)
goto out;
if (file->f_mode & FMODE_READ) {
ret = seq_open(file, &kmemleak_seq_ops);
if (ret < 0)
goto scan_unlock;
}
>>- return ret;

scan_unlock:
mutex_unlock(&scan_mutex);
out:
return ret;
}

we should not return before mutex_unlock(&scan_mutex);

Sergey


Attachments:
(No filename) (928.00 B)
signature.asc (315.00 B)
Digital signature
Download all attachments

2009-07-09 10:47:52

by Catalin Marinas

[permalink] [raw]
Subject: Re: kmemeleak BUG: lock held when returning to user space!

Sergey Senozhatsky <[email protected]> wrote:
> kernel: [ 149.507103] ================================================
> kernel: [ 149.507113] [ BUG: lock held when returning to user space! ]
> kernel: [ 149.507119] ------------------------------------------------
> kernel: [ 149.507127] cat/3279 is leaving the kernel with locks still held!
> kernel: [ 149.507135] 1 lock held by cat/3279:
> kernel: [ 149.507141] #0: (scan_mutex){+.+.+.}, at: [<c110707c>] kmemleak_open+0x4c/0x80
>
> problem is here:
> static int kmemleak_open(struct inode *inode, struct file *file)

It's been fixed in my kmemleak branch which I'll push to Linus:

http://www.linux-arm.org/git?p=linux-2.6.git;a=shortlog;h=kmemleak

--
Catalin

2009-07-09 10:54:23

by Sergey Senozhatsky

[permalink] [raw]
Subject: Re: kmemeleak BUG: lock held when returning to user space!

On (07/09/09 11:47), Catalin Marinas wrote:
> Date: Thu, 09 Jul 2009 11:47:23 +0100
> From: Catalin Marinas <[email protected]>
> To: Sergey Senozhatsky <[email protected]>
> Cc: Pekka Enberg <[email protected]>,
> "Paul E. McKenney" <[email protected]>,
> [email protected], [email protected]
> Subject: Re: kmemeleak BUG: lock held when returning to user space!
> User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)
>
> Sergey Senozhatsky <[email protected]> wrote:
> > kernel: [ 149.507103] ================================================
> > kernel: [ 149.507113] [ BUG: lock held when returning to user space! ]
> > kernel: [ 149.507119] ------------------------------------------------
> > kernel: [ 149.507127] cat/3279 is leaving the kernel with locks still held!
> > kernel: [ 149.507135] 1 lock held by cat/3279:
> > kernel: [ 149.507141] #0: (scan_mutex){+.+.+.}, at: [<c110707c>] kmemleak_open+0x4c/0x80
> >
> > problem is here:
> > static int kmemleak_open(struct inode *inode, struct file *file)
>
> It's been fixed in my kmemleak branch which I'll push to Linus:
>
Ok. Nice to hear.

> http://www.linux-arm.org/git?p=linux-2.6.git;a=shortlog;h=kmemleak
>
> --
> Catalin
>

Sergey


Attachments:
(No filename) (1.24 kB)
signature.asc (315.00 B)
Digital signature
Download all attachments