From: Heinz Mauelshagen <heinzm@xxxxxxxxxx> Signed-off-by: Heinz Mauelshagen <heinzm@xxxxxxxxxx> Signed-off-by: Mike Snitzer <snitzer@xxxxxxxxxx> --- drivers/md/dm-crypt.c | 9 ++++++--- drivers/md/dm-stats.c | 3 ++- drivers/md/dm-table.c | 3 ++- 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 6a58000f58d7..98c788d1b305 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 861e6f97438b..3287c0a9dd04 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 af0a214825d6..d5a3f73de4bf 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 431c84595ddb..369b2a99e459 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; } -- 2.37.0 (Apple Git-136) -- dm-devel mailing list dm-devel@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/dm-devel