[PATCH] slimbus: qcom-ctrl: fix possible memory leak in qcom_slim_probe()

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

 



The kfree() should be called to free ctrl->wr_comp when something
fails, we should also free it in qcom_slim_remove(), otherwise
there will be a memory leak, so use devm_kcalloc instead of kcalloc
to fix it.

Fixes: ad7fcbc308b0 ("slimbus: qcom: Add Qualcomm Slimbus controller driver")
Signed-off-by: Gaosheng Cui <cuigaosheng1@xxxxxxxxxx>
---
 drivers/slimbus/qcom-ctrl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/slimbus/qcom-ctrl.c b/drivers/slimbus/qcom-ctrl.c
index 400b7b385a44..e4d92ce52c41 100644
--- a/drivers/slimbus/qcom-ctrl.c
+++ b/drivers/slimbus/qcom-ctrl.c
@@ -529,8 +529,8 @@ static int qcom_slim_probe(struct platform_device *pdev)
 	ctrl->tx.sl_sz = SLIM_MSGQ_BUF_LEN;
 	ctrl->rx.n = QCOM_RX_MSGS;
 	ctrl->rx.sl_sz = SLIM_MSGQ_BUF_LEN;
-	ctrl->wr_comp = kcalloc(QCOM_TX_MSGS, sizeof(struct completion *),
-				GFP_KERNEL);
+	ctrl->wr_comp = devm_kcalloc(&pdev->dev, QCOM_TX_MSGS, sizeof(struct completion *),
+				     GFP_KERNEL);
 	if (!ctrl->wr_comp)
 		return -ENOMEM;
 
-- 
2.25.1




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux