All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dmaengine: idxd: double free of devm_ memory on probe error
@ 2021-05-08  8:20 Dan Carpenter
  2021-05-10  0:38 ` [PATCH] dmaengine: idxd: remove devm allocation for idxd->int_handles Dave Jiang
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2021-05-08  8:20 UTC (permalink / raw)
  To: Dave Jiang; +Cc: Vinod Koul, dmaengine, kernel-janitors

The "idxd->int_handles" pointer is allocated with devm_kcalloc() so
freeing it here leads to a double free.  Delete the kfree().

Fixes: eb15e7154fbf ("dmaengine: idxd: add interrupt handle request and release support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/dma/idxd/init.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c
index 2a926bef87f2..b65d28895955 100644
--- a/drivers/dma/idxd/init.c
+++ b/drivers/dma/idxd/init.c
@@ -318,7 +318,7 @@ static int idxd_setup_internals(struct idxd_device *idxd)
 
 	rc = idxd_setup_wqs(idxd);
 	if (rc < 0)
-		goto err_wqs;
+		return rc;
 
 	rc = idxd_setup_engines(idxd);
 	if (rc < 0)
@@ -345,8 +345,6 @@ static int idxd_setup_internals(struct idxd_device *idxd)
  err_engine:
 	for (i = 0; i < idxd->max_wqs; i++)
 		put_device(&idxd->wqs[i]->conf_dev);
- err_wqs:
-	kfree(idxd->int_handles);
 	return rc;
 }
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] dmaengine: idxd: remove devm allocation for idxd->int_handles
  2021-05-08  8:20 [PATCH] dmaengine: idxd: double free of devm_ memory on probe error Dan Carpenter
@ 2021-05-10  0:38 ` Dave Jiang
  2021-05-10 15:50   ` Vinod Koul
  0 siblings, 1 reply; 3+ messages in thread
From: Dave Jiang @ 2021-05-10  0:38 UTC (permalink / raw)
  To: vkoul; +Cc: Dan Carpenter, dmaengine, kernel-janitors

Allocation of idxd->int_handles was merged incorrectly for the 5.13 merge
window. The devm_kcalloc should've been regular kcalloc due to devm_*
removal series for the driver.

Fixes: eb15e7154fbf ("dmaengine: idxd: add interrupt handle request and release support")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
 drivers/dma/idxd/init.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c
index 2a926bef87f2..21d3dcb1c0e3 100644
--- a/drivers/dma/idxd/init.c
+++ b/drivers/dma/idxd/init.c
@@ -311,7 +311,8 @@ static int idxd_setup_internals(struct idxd_device *idxd)
 	init_waitqueue_head(&idxd->cmd_waitq);
 
 	if (idxd->hw.cmd_cap & BIT(IDXD_CMD_REQUEST_INT_HANDLE)) {
-		idxd->int_handles = devm_kcalloc(dev, idxd->max_wqs, sizeof(int), GFP_KERNEL);
+		idxd->int_handles = kcalloc_node(idxd->max_wqs, sizeof(int), GFP_KERNEL,
+						 dev_to_node(dev));
 		if (!idxd->int_handles)
 			return -ENOMEM;
 	}



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] dmaengine: idxd: remove devm allocation for idxd->int_handles
  2021-05-10  0:38 ` [PATCH] dmaengine: idxd: remove devm allocation for idxd->int_handles Dave Jiang
@ 2021-05-10 15:50   ` Vinod Koul
  0 siblings, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2021-05-10 15:50 UTC (permalink / raw)
  To: Dave Jiang; +Cc: Dan Carpenter, dmaengine, kernel-janitors

On 09-05-21, 17:38, Dave Jiang wrote:
> Allocation of idxd->int_handles was merged incorrectly for the 5.13 merge
> window. The devm_kcalloc should've been regular kcalloc due to devm_*
> removal series for the driver.

Applied, thanks

-- 
~Vinod

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-10 15:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-08  8:20 [PATCH] dmaengine: idxd: double free of devm_ memory on probe error Dan Carpenter
2021-05-10  0:38 ` [PATCH] dmaengine: idxd: remove devm allocation for idxd->int_handles Dave Jiang
2021-05-10 15:50   ` Vinod Koul

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.