Commit ec2c64e2 authored by Marcus Folkesson's avatar Marcus Folkesson Committed by Kalle Valo

ath10k: sdio: fix memory leak for probe allocations

These allocations are not freed upon release.
When on it; go for managed resources instead.
Signed-off-by: default avatarMarcus Folkesson <marcus.folkesson@gmail.com>
[kvalo: fix two checkpatch warnings]
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent db5a4d5e
...@@ -1957,25 +1957,25 @@ static int ath10k_sdio_probe(struct sdio_func *func, ...@@ -1957,25 +1957,25 @@ static int ath10k_sdio_probe(struct sdio_func *func,
ar_sdio = ath10k_sdio_priv(ar); ar_sdio = ath10k_sdio_priv(ar);
ar_sdio->irq_data.irq_proc_reg = ar_sdio->irq_data.irq_proc_reg =
kzalloc(sizeof(struct ath10k_sdio_irq_proc_regs), devm_kzalloc(ar->dev, sizeof(struct ath10k_sdio_irq_proc_regs),
GFP_KERNEL); GFP_KERNEL);
if (!ar_sdio->irq_data.irq_proc_reg) { if (!ar_sdio->irq_data.irq_proc_reg) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_core_destroy; goto err_core_destroy;
} }
ar_sdio->irq_data.irq_en_reg = ar_sdio->irq_data.irq_en_reg =
kzalloc(sizeof(struct ath10k_sdio_irq_enable_regs), devm_kzalloc(ar->dev, sizeof(struct ath10k_sdio_irq_enable_regs),
GFP_KERNEL); GFP_KERNEL);
if (!ar_sdio->irq_data.irq_en_reg) { if (!ar_sdio->irq_data.irq_en_reg) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_free_proc_reg; goto err_core_destroy;
} }
ar_sdio->bmi_buf = kzalloc(BMI_MAX_CMDBUF_SIZE, GFP_KERNEL); ar_sdio->bmi_buf = devm_kzalloc(ar->dev, BMI_MAX_CMDBUF_SIZE, GFP_KERNEL);
if (!ar_sdio->bmi_buf) { if (!ar_sdio->bmi_buf) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_free_en_reg; goto err_core_destroy;
} }
ar_sdio->func = func; ar_sdio->func = func;
...@@ -1995,7 +1995,7 @@ static int ath10k_sdio_probe(struct sdio_func *func, ...@@ -1995,7 +1995,7 @@ static int ath10k_sdio_probe(struct sdio_func *func,
ar_sdio->workqueue = create_singlethread_workqueue("ath10k_sdio_wq"); ar_sdio->workqueue = create_singlethread_workqueue("ath10k_sdio_wq");
if (!ar_sdio->workqueue) { if (!ar_sdio->workqueue) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_free_bmi_buf; goto err_core_destroy;
} }
for (i = 0; i < ATH10K_SDIO_BUS_REQUEST_MAX_NUM; i++) for (i = 0; i < ATH10K_SDIO_BUS_REQUEST_MAX_NUM; i++)
...@@ -2011,7 +2011,7 @@ static int ath10k_sdio_probe(struct sdio_func *func, ...@@ -2011,7 +2011,7 @@ static int ath10k_sdio_probe(struct sdio_func *func,
ret = -ENODEV; ret = -ENODEV;
ath10k_err(ar, "unsupported device id %u (0x%x)\n", ath10k_err(ar, "unsupported device id %u (0x%x)\n",
dev_id_base, id->device); dev_id_base, id->device);
goto err_free_bmi_buf; goto err_core_destroy;
} }
ar->id.vendor = id->vendor; ar->id.vendor = id->vendor;
...@@ -2040,12 +2040,6 @@ static int ath10k_sdio_probe(struct sdio_func *func, ...@@ -2040,12 +2040,6 @@ static int ath10k_sdio_probe(struct sdio_func *func,
err_free_wq: err_free_wq:
destroy_workqueue(ar_sdio->workqueue); destroy_workqueue(ar_sdio->workqueue);
err_free_bmi_buf:
kfree(ar_sdio->bmi_buf);
err_free_en_reg:
kfree(ar_sdio->irq_data.irq_en_reg);
err_free_proc_reg:
kfree(ar_sdio->irq_data.irq_proc_reg);
err_core_destroy: err_core_destroy:
ath10k_core_destroy(ar); ath10k_core_destroy(ar);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment