diff options
author | Heinz Mauelshagen <heinzm@redhat.com> | 2023-02-01 23:17:44 +0300 |
---|---|---|
committer | Mike Snitzer <snitzer@kernel.org> | 2023-02-14 22:23:06 +0300 |
commit | d715fa23577cd5d36830c4ecd7e2bfcb4750b351 (patch) | |
tree | 996c4ce089ec9338a118706c219d6866690731e3 /drivers/md | |
parent | 86a3238c7b9b759cb864f4f768ab2e24687dc0e6 (diff) | |
download | linux-d715fa23577cd5d36830c4ecd7e2bfcb4750b351.tar.xz |
dm: avoid assignment in if conditions
Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/dm-crypt.c | 9 | ||||
-rw-r--r-- | drivers/md/dm-stats.c | 3 | ||||
-rw-r--r-- | drivers/md/dm-table.c | 3 | ||||
-rw-r--r-- | drivers/md/dm-writecache.c | 11 |
4 files changed, 17 insertions, 9 deletions
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index aeb8b19ddc34..ef97a28754cd 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -3416,9 +3416,12 @@ static int crypt_map(struct dm_target *ti, struct bio *bio) if (cc->on_disk_tag_size) { unsigned int tag_len = cc->on_disk_tag_size * (bio_sectors(bio) >> cc->sector_shift); - if (unlikely(tag_len > KMALLOC_MAX_SIZE) || - unlikely(!(io->integrity_metadata = kmalloc(tag_len, - GFP_NOIO | __GFP_NORETRY | __GFP_NOMEMALLOC | __GFP_NOWARN)))) { + if (unlikely(tag_len > KMALLOC_MAX_SIZE)) + io->integrity_metadata = NULL; + else + io->integrity_metadata = kmalloc(tag_len, GFP_NOIO | __GFP_NORETRY | __GFP_NOMEMALLOC | __GFP_NOWARN); + + if (unlikely(!io->integrity_metadata)) { if (bio_sectors(bio) > cc->tag_pool_max_sectors) dm_accept_partial_bio(bio, cc->tag_pool_max_sectors); io->integrity_metadata = mempool_alloc(&cc->tag_pool, GFP_NOIO); diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c index 1a94fb0e44f1..b738f565bf5a 100644 --- a/drivers/md/dm-stats.c +++ b/drivers/md/dm-stats.c @@ -1046,7 +1046,8 @@ static int message_stats_create(struct mapped_device *md, else if (!strncasecmp(a, "histogram:", 10)) { if (n_histogram_entries) goto ret_einval; - if ((r = parse_histogram(a + 10, &n_histogram_entries, &histogram_boundaries))) + r = parse_histogram(a + 10, &n_histogram_entries, &histogram_boundaries); + if (r) goto ret; } else goto ret_einval; diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 455d7303e278..cf1b43724fc5 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -374,7 +374,8 @@ int dm_get_device(struct dm_target *ti, const char *path, fmode_t mode, if (!dd) return -ENOMEM; - if ((r = dm_get_table_device(t->md, dev, mode, &dd->dm_dev))) { + r = dm_get_table_device(t->md, dev, mode, &dd->dm_dev); + if (r) { kfree(dd); return r; } diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index 17e064cde712..69aa708d6dae 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -1832,10 +1832,13 @@ static void __writecache_writeback_pmem(struct dm_writecache *wc, struct writeba wb->wc = wc; bio->bi_end_io = writecache_writeback_endio; bio->bi_iter.bi_sector = read_original_sector(wc, e); - if (max_pages <= WB_LIST_INLINE || - unlikely(!(wb->wc_list = kmalloc_array(max_pages, sizeof(struct wc_entry *), - GFP_NOIO | __GFP_NORETRY | - __GFP_NOMEMALLOC | __GFP_NOWARN)))) { + + if (unlikely(max_pages > WB_LIST_INLINE)) + wb->wc_list = kmalloc_array(max_pages, sizeof(struct wc_entry *), + GFP_NOIO | __GFP_NORETRY | + __GFP_NOMEMALLOC | __GFP_NOWARN); + + if (likely(max_pages <= WB_LIST_INLINE) || unlikely(!wb->wc_list)) { wb->wc_list = wb->wc_list_inline; max_pages = WB_LIST_INLINE; } |