[PATCH][next] dm ima: Fix resource leaks on error return path

From: Colin King
Date: Tue Aug 03 2021 - 11:42:53 EST


From: Colin Ian King <colin.king@xxxxxxxxxxxxx>

Currently there is an error check on r that immediately returns
on an error rather than taking the error clean-up exit path via
label 'error'. Fix this to avoid resource leaks.

Addresses-Coverity: ("Resourced leak")
Fixes: 0a3bec81a409 ("dm ima: measure data on table load")
Signed-off-by: Colin Ian King <colin.king@xxxxxxxxxxxxx>
---
drivers/md/dm-ima.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/dm-ima.c b/drivers/md/dm-ima.c
index 2d796e439bee..91ea4a7202ab 100644
--- a/drivers/md/dm-ima.c
+++ b/drivers/md/dm-ima.c
@@ -216,7 +216,7 @@ void dm_ima_measure_on_table_load(struct dm_table *table, unsigned int status_fl

r = crypto_shash_init(shash);
if (r)
- return;
+ goto error;

device_data_buf_len = strlen(device_data_buf);
memcpy(ima_buf + l, device_data_buf, device_data_buf_len);
--
2.31.1