Skip to contentSkip to conversation

dm: fix uninitialized variable use

PATCH New Damien Le Moal 1 participant 1 message Jun 4, 2021 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm: fix uninitialized variable use

From: Damien Le Moal <[email protected]>

In dm_io_dec_pending(), make sure that the bio variable is initialized to io->orig_bio before using it.

Fixes 3a1e343c53ae ("dm: Forbid requeue of writes to zones")
---
 drivers/md/dm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/dm.c +2 -2
index a89bb9bbe82d..e687d60212b6 100644
@@ -796,6 +796,7 @@ void dm_io_dec_pending(struct dm_io *io, blk_status_t error)
 	}
 
 	if (atomic_dec_and_test(&io->io_count)) {
+		bio = io->orig_bio;
 		if (io->status == BLK_STS_DM_REQUEUE) {
 			/*
 			 * Target requested pushing back the I/O.
@@ -804,7 +805,7 @@ void dm_io_dec_pending(struct dm_io *io, blk_status_t error)
 			if (__noflush_suspending(md) &&
 			    !WARN_ON_ONCE(dm_is_zone_write(md, bio)))
 				/* NOTE early return due to BLK_STS_DM_REQUEUE below */
-				bio_list_add_head(&md->deferred, io->orig_bio);
+				bio_list_add_head(&md->deferred, bio);
 			else
 				/*
 				 * noflush suspend was interrupted or this is
@@ -815,7 +816,6 @@ void dm_io_dec_pending(struct dm_io *io, blk_status_t error)
 		}
 
 		io_error = io->status;
-		bio = io->orig_bio;
 		end_io_acct(io);
 		free_io(md, io);
 
Signature · 7 lines
2.31.1


--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel