diff options
| author | Shuai Xue <xueshuai@linux.alibaba.com> | 2025-04-04 20:02:10 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-05-22 14:10:07 +0200 |
| commit | 11fd63ea08b9ff18a9020bf48be2aee34920590d (patch) | |
| tree | 282b1379f64cfff3a9c73f8fc2a21aff67a1c6a3 /drivers/dma | |
| parent | d584acdf54f409cb7eae1359ae6c12aaabedeed8 (diff) | |
| download | linux-11fd63ea08b9ff18a9020bf48be2aee34920590d.tar.gz linux-11fd63ea08b9ff18a9020bf48be2aee34920590d.tar.bz2 linux-11fd63ea08b9ff18a9020bf48be2aee34920590d.zip | |
dmaengine: idxd: fix memory leak in error handling path of idxd_setup_engines
commit 817bced19d1dbdd0b473580d026dc0983e30e17b upstream.
Memory allocated for engines is not freed if an error occurs during
idxd_setup_engines(). To fix it, free the allocated memory in the
reverse order of allocation before exiting the function in case of an
error.
Fixes: 75b911309060 ("dmaengine: idxd: fix engine conf_dev lifetime")
Cc: stable@vger.kernel.org
Signed-off-by: Shuai Xue <xueshuai@linux.alibaba.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Fenghua Yu <fenghuay@nvidia.com>
Link: https://lore.kernel.org/r/20250404120217.48772-3-xueshuai@linux.alibaba.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/dma')
| -rw-r--r-- | drivers/dma/idxd/init.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c index 9763769b301c..fef609cde83e 100644 --- a/drivers/dma/idxd/init.c +++ b/drivers/dma/idxd/init.c @@ -259,6 +259,7 @@ static int idxd_setup_engines(struct idxd_device *idxd) rc = dev_set_name(conf_dev, "engine%d.%d", idxd->id, engine->id); if (rc < 0) { put_device(conf_dev); + kfree(engine); goto err; } @@ -272,7 +273,10 @@ static int idxd_setup_engines(struct idxd_device *idxd) engine = idxd->engines[i]; conf_dev = engine_confdev(engine); put_device(conf_dev); + kfree(engine); } + kfree(idxd->engines); + return rc; } |
