Fix synchronization issue in mods kernel driver

Summary: The get_reset_handle function does not
release the spin_lock when it finds the handle in
the list of reset handles and returns. Modify the
function to ensure releasing of the lock in all
cases.

Change-Id: I2ead6d64199cccc7afb7876ca14ce91a110f7e6c
Signed-off-by: Ellis Roberts <ellisr@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2365950
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
root
2020-06-23 22:10:27 -07:00
committed by Laxman Dewangan
parent 9e88fe9bb3
commit 12952ac5dc

View File

@@ -220,22 +220,23 @@ static int get_reset_handle(struct reset_data reset_data)
handle = rst_entry->handle;
if (strcmp(rst_entry->rst_data.name,
reset_data.name) == 0) {
return handle;
goto failed;
}
}
/* If reset not already in array, then we must add it */
rst_entry = kzalloc(sizeof(struct reset_entry), GFP_ATOMIC);
if (unlikely(!rst_entry)) {
spin_unlock(&mods_clock_lock);
return -1;
handle = -1;
goto failed;
}
rst_entry->handle = ++handle;
rst_entry->rst_data = reset_data;
INIT_LIST_HEAD(&rst_entry->list);
list_add_tail(&rst_entry->list, &reset_handles);
spin_unlock(&mods_clock_lock);
failed:
spin_unlock(&mods_clock_lock);
return handle;
}