kmemeleak BUG: lock held when returning to user space!

From: Sergey Senozhatsky
Date: Thu Jul 09 2009 - 06:40:21 EST


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

Attachment: signature.asc
Description: Digital signature