提交 e5a0726a 编写于 作者: A Al Viro

logfs: fix a leak in get_sb

a) switch ->put_device() to logfs_super *
b) actually call it on early failures in logfs_get_sb_device()
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 7d945a3a
......@@ -298,9 +298,9 @@ static int bdev_write_sb(struct super_block *sb, struct page *page)
return sync_request(page, bdev, WRITE);
}
static void bdev_put_device(struct super_block *sb)
static void bdev_put_device(struct logfs_super *s)
{
close_bdev_exclusive(logfs_super(sb)->s_bdev, FMODE_READ|FMODE_WRITE);
close_bdev_exclusive(s->s_bdev, FMODE_READ|FMODE_WRITE);
}
static int bdev_can_write_buf(struct super_block *sb, u64 ofs)
......
......@@ -230,9 +230,9 @@ static void mtd_writeseg(struct super_block *sb, u64 ofs, size_t len)
__mtd_writeseg(sb, ofs, ofs >> PAGE_SHIFT, len >> PAGE_SHIFT);
}
static void mtd_put_device(struct super_block *sb)
static void mtd_put_device(struct logfs_super *s)
{
put_mtd_device(logfs_super(sb)->s_mtd);
put_mtd_device(s->s_mtd);
}
static int mtd_can_write_buf(struct super_block *sb, u64 ofs)
......
......@@ -136,6 +136,7 @@ struct logfs_area_ops {
int (*erase_segment)(struct logfs_area *area);
};
struct logfs_super; /* forward */
/**
* struct logfs_device_ops - device access operations
*
......@@ -156,7 +157,7 @@ struct logfs_device_ops {
int ensure_write);
int (*can_write_buf)(struct super_block *sb, u64 ofs);
void (*sync)(struct super_block *sb);
void (*put_device)(struct super_block *sb);
void (*put_device)(struct logfs_super *s);
};
/**
......
......@@ -529,7 +529,7 @@ static void logfs_kill_sb(struct super_block *sb)
logfs_cleanup_rw(sb);
if (super->s_erase_page)
__free_page(super->s_erase_page);
super->s_devops->put_device(sb);
super->s_devops->put_device(super);
logfs_mempool_destroy(super->s_btree_pool);
logfs_mempool_destroy(super->s_alias_pool);
kfree(super);
......@@ -586,8 +586,8 @@ int logfs_get_sb_device(struct logfs_super *super,
deactivate_locked_super(sb);
return err;
err0:
super->s_devops->put_device(super);
kfree(super);
//devops->put_device(sb);
return err;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册