提交 766a7888 编写于 作者: J Joe Thornber 提交者: Mike Snitzer

dm cache: fix missing ERR_PTR returns and handling

Commit 9b1cc9f2 ("dm cache: share cache-metadata object across
inactive and active DM tables") mistakenly ignored the use of ERR_PTR
returns.  Restore missing IS_ERR checks and ERR_PTR returns where
appropriate.
Reported-by: NDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: NJoe Thornber <ejt@redhat.com>
Signed-off-by: NMike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org
上级 26bc420b
...@@ -683,7 +683,7 @@ static struct dm_cache_metadata *metadata_open(struct block_device *bdev, ...@@ -683,7 +683,7 @@ static struct dm_cache_metadata *metadata_open(struct block_device *bdev,
cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
if (!cmd) { if (!cmd) {
DMERR("could not allocate metadata struct"); DMERR("could not allocate metadata struct");
return NULL; return ERR_PTR(-ENOMEM);
} }
atomic_set(&cmd->ref_count, 1); atomic_set(&cmd->ref_count, 1);
...@@ -745,7 +745,7 @@ static struct dm_cache_metadata *lookup_or_open(struct block_device *bdev, ...@@ -745,7 +745,7 @@ static struct dm_cache_metadata *lookup_or_open(struct block_device *bdev,
return cmd; return cmd;
cmd = metadata_open(bdev, data_block_size, may_format_device, policy_hint_size); cmd = metadata_open(bdev, data_block_size, may_format_device, policy_hint_size);
if (cmd) { if (!IS_ERR(cmd)) {
mutex_lock(&table_lock); mutex_lock(&table_lock);
cmd2 = lookup(bdev); cmd2 = lookup(bdev);
if (cmd2) { if (cmd2) {
...@@ -780,9 +780,10 @@ struct dm_cache_metadata *dm_cache_metadata_open(struct block_device *bdev, ...@@ -780,9 +780,10 @@ struct dm_cache_metadata *dm_cache_metadata_open(struct block_device *bdev,
{ {
struct dm_cache_metadata *cmd = lookup_or_open(bdev, data_block_size, struct dm_cache_metadata *cmd = lookup_or_open(bdev, data_block_size,
may_format_device, policy_hint_size); may_format_device, policy_hint_size);
if (cmd && !same_params(cmd, data_block_size)) {
if (!IS_ERR(cmd) && !same_params(cmd, data_block_size)) {
dm_cache_metadata_close(cmd); dm_cache_metadata_close(cmd);
return NULL; return ERR_PTR(-EINVAL);
} }
return cmd; return cmd;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册