Skip to content

Commit

Permalink
dm vdo indexer-volume: fix missing mutex_lock in process_entry
Browse files Browse the repository at this point in the history
Must mutex_lock after dm_bufio_read, before dm_bufio_read error
handling, otherwise process_entry error path will return without
volume->read_threads_mutex held. This fixes potential double
mutex_unlock.

Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: Mike Snitzer <[email protected]>
Signed-off-by: Susan LeGendre-McGhee <[email protected]>
Signed-off-by: Matthew Sakai <[email protected]>
  • Loading branch information
Mike Snitzer authored and lorelei-sakai committed Feb 20, 2024
1 parent f596e9c commit 8d76c76
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/md/dm-vdo/volume.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ static int process_entry(struct volume *volume, struct queued_read *entry)

mutex_unlock(&volume->read_threads_mutex);
page_data = dm_bufio_read(volume->client, page_number, &page->buffer);
mutex_lock(&volume->read_threads_mutex);
if (IS_ERR(page_data)) {
result = -PTR_ERR(page_data);
uds_log_warning_strerror(result,
Expand All @@ -564,7 +565,6 @@ static int process_entry(struct volume *volume, struct queued_read *entry)
cancel_page_in_cache(&volume->page_cache, page_number, page);
return result;
}
mutex_lock(&volume->read_threads_mutex);

if (entry->invalid) {
uds_log_warning("Page %u invalidated after read", page_number);
Expand Down

0 comments on commit 8d76c76

Please sign in to comment.