dm-integrity: set ti->error on memory allocation failure
authorMikulas Patocka <mpatocka@redhat.com>
Mon, 10 Feb 2025 15:14:22 +0000 (16:14 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 25 Apr 2025 08:45:34 +0000 (10:45 +0200)
commit 00204ae3d6712ee053353920e3ce2b00c35ef75b upstream.

The dm-integrity target didn't set the error string when memory
allocation failed. This patch fixes it.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/dm-integrity.c

index a36dd749c688e118c1862ac63e65b1855770c22f..eb2b44f4a61f08963f074d3420b346578a511ff2 100644 (file)
@@ -4594,16 +4594,19 @@ try_smaller_buffer:
 
                ic->recalc_bitmap = dm_integrity_alloc_page_list(n_bitmap_pages);
                if (!ic->recalc_bitmap) {
+                       ti->error = "Could not allocate memory for bitmap";
                        r = -ENOMEM;
                        goto bad;
                }
                ic->may_write_bitmap = dm_integrity_alloc_page_list(n_bitmap_pages);
                if (!ic->may_write_bitmap) {
+                       ti->error = "Could not allocate memory for bitmap";
                        r = -ENOMEM;
                        goto bad;
                }
                ic->bbs = kvmalloc_array(ic->n_bitmap_blocks, sizeof(struct bitmap_block_status), GFP_KERNEL);
                if (!ic->bbs) {
+                       ti->error = "Could not allocate memory for bitmap";
                        r = -ENOMEM;
                        goto bad;
                }