[PATCH 4/4] dm cache metadata: Avoid use-after-free in dm_cache_metadata_set_read_only

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Ye Bin <yebin10@xxxxxxxxxx>
---
 drivers/md/dm-cache-metadata.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm-cache-metadata.c b/drivers/md/dm-cache-metadata.c
index af6d4f898e4c..397b0fc04c8d 100644
--- a/drivers/md/dm-cache-metadata.c
+++ b/drivers/md/dm-cache-metadata.c
@@ -1761,14 +1761,16 @@ int dm_cache_metadata_all_clean(struct dm_cache_metadata *cmd, bool *result)
 void dm_cache_metadata_set_read_only(struct dm_cache_metadata *cmd)
 {
 	WRITE_LOCK_VOID(cmd);
-	dm_bm_set_read_only(cmd->bm);
+	if (cmd->bm)
+		dm_bm_set_read_only(cmd->bm);
 	WRITE_UNLOCK(cmd);
 }
 
 void dm_cache_metadata_set_read_write(struct dm_cache_metadata *cmd)
 {
 	WRITE_LOCK_VOID(cmd);
-	dm_bm_set_read_write(cmd->bm);
+	if (cmd->bm)
+		dm_bm_set_read_write(cmd->bm);
 	WRITE_UNLOCK(cmd);
 }
 
-- 
2.25.4


--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux