Commit bc8eeafab3b7e4f79ea422d50753160a005f4e15
Committed by
Greg Kroah-Hartman
1 parent
e046f3ddf3
dm cache: fix missing ERR_PTR returns and handling
commit 766a78882ddf79b162243649d7dfdbac1fb6fb88 upstream. Commit 9b1cc9f251 ("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: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Joe Thornber <ejt@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Showing 1 changed file with 5 additions and 4 deletions Side-by-side Diff
drivers/md/dm-cache-metadata.c
... | ... | @@ -683,7 +683,7 @@ |
683 | 683 | cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); |
684 | 684 | if (!cmd) { |
685 | 685 | DMERR("could not allocate metadata struct"); |
686 | - return NULL; | |
686 | + return ERR_PTR(-ENOMEM); | |
687 | 687 | } |
688 | 688 | |
689 | 689 | atomic_set(&cmd->ref_count, 1); |
... | ... | @@ -745,7 +745,7 @@ |
745 | 745 | return cmd; |
746 | 746 | |
747 | 747 | cmd = metadata_open(bdev, data_block_size, may_format_device, policy_hint_size); |
748 | - if (cmd) { | |
748 | + if (!IS_ERR(cmd)) { | |
749 | 749 | mutex_lock(&table_lock); |
750 | 750 | cmd2 = lookup(bdev); |
751 | 751 | if (cmd2) { |
752 | 752 | |
... | ... | @@ -780,9 +780,10 @@ |
780 | 780 | { |
781 | 781 | struct dm_cache_metadata *cmd = lookup_or_open(bdev, data_block_size, |
782 | 782 | may_format_device, policy_hint_size); |
783 | - if (cmd && !same_params(cmd, data_block_size)) { | |
783 | + | |
784 | + if (!IS_ERR(cmd) && !same_params(cmd, data_block_size)) { | |
784 | 785 | dm_cache_metadata_close(cmd); |
785 | - return NULL; | |
786 | + return ERR_PTR(-EINVAL); | |
786 | 787 | } |
787 | 788 | |
788 | 789 | return cmd; |