mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mm: fix refcounting in swapon
@ 2011-02-24 14:49 Miklos Szeredi
  2011-02-24 14:55 ` Tejun Heo
  0 siblings, 1 reply; 2+ messages in thread
From: Miklos Szeredi @ 2011-02-24 14:49 UTC (permalink / raw)
  To: akpm, torvalds; +Cc: rjw, tj, linux-kernel

From: Miklos Szeredi <mszeredi@suse.cz>

Grab a reference to bdev before calling blkdev_get(), which expects
the refcount to be already incremented and either returns success or
decrements the refcount and returns an error.

The bug was introduced by e525fd89 (block: make blkdev_get/put()
handle exclusive access), which didn't take into account this behavior
of blkdev_get().

CC: Tejun Heo <tj@kernel.org>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
 mm/swapfile.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux.git/mm/swapfile.c
===================================================================
--- linux.git.orig/mm/swapfile.c	2011-02-24 15:29:26.000000000 +0100
+++ linux.git/mm/swapfile.c	2011-02-24 15:32:31.000000000 +0100
@@ -1940,7 +1940,7 @@ SYSCALL_DEFINE2(swapon, const char __use
 
 	error = -EINVAL;
 	if (S_ISBLK(inode->i_mode)) {
-		bdev = I_BDEV(inode);
+		bdev = bdgrab(I_BDEV(inode));
 		error = blkdev_get(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL,
 				   sys_swapon);
 		if (error < 0) {

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] mm: fix refcounting in swapon
  2011-02-24 14:49 [PATCH] mm: fix refcounting in swapon Miklos Szeredi
@ 2011-02-24 14:55 ` Tejun Heo
  0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2011-02-24 14:55 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: akpm, torvalds, rjw, linux-kernel

On Thu, Feb 24, 2011 at 03:49:53PM +0100, Miklos Szeredi wrote:
> From: Miklos Szeredi <mszeredi@suse.cz>
> 
> Grab a reference to bdev before calling blkdev_get(), which expects
> the refcount to be already incremented and either returns success or
> decrements the refcount and returns an error.
> 
> The bug was introduced by e525fd89 (block: make blkdev_get/put()
> handle exclusive access), which didn't take into account this behavior
> of blkdev_get().
> 
> CC: Tejun Heo <tj@kernel.org>
> Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>

Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-02-24 14:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-24 14:49 [PATCH] mm: fix refcounting in swapon Miklos Szeredi
2011-02-24 14:55 ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®