slimbus: slim-msm-ngd: Fix a memory leak in error handling
In one of the error handling scenarios during probe, slimbus NGD driver
does not release the memory allocated prior to the error scenario.
Fix the memory leak by freeing any prior memory allocation during an error.
CRs-Fixed: 2002163
Change-Id: I2f718637d0d3cee2b110baed74f2b9bf479aa144
Signed-off-by: Karthikeyan Ramasubramanian <kramasub@codeaurora.org>
diff --git a/drivers/slimbus/slim-msm-ngd.c b/drivers/slimbus/slim-msm-ngd.c
index 969d162..f7f0269 100644
--- a/drivers/slimbus/slim-msm-ngd.c
+++ b/drivers/slimbus/slim-msm-ngd.c
@@ -1707,8 +1707,10 @@
}
dev->wr_comp = kzalloc(sizeof(struct completion *) * MSM_TX_BUFS,
GFP_KERNEL);
- if (!dev->wr_comp)
- return -ENOMEM;
+ if (!dev->wr_comp) {
+ ret = -ENOMEM;
+ goto err_nobulk;
+ }
/* typical txn numbers and size used in bulk operation */
dev->bulk.buf_sz = SLIM_MAX_TXNS * 8;