[dm-devel] [PATCH] dm: fix uninitialized variable use

Damien Le Moal damien.lemoal at opensource.wdc.com
Fri Jun 4 00:47:03 UTC 2021


From: Damien Le Moal <damien.lemoal at wdc.com>

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

Reported-by: kernel test robot <lkp at intel.com>
Fixes: 3a1e343c53ae ("dm: Forbid requeue of writes to zones")
Signed-off-by: Damien Le Moal <damien.lemoal at wdc.com>
---
 drivers/md/dm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index a89bb9bbe82d..e687d60212b6 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -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);
 
-- 
2.31.1





More information about the dm-devel mailing list