diff options
| author | Shuai Xue <xueshuai@linux.alibaba.com> | 2025-04-04 20:02:15 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-05-22 14:29:52 +0200 |
| commit | 017d4012dc05972ce95c2f487725a7a38e24552a (patch) | |
| tree | 2bb2a40448759733637dd000bc3e7f54c1e67cf7 /drivers/dma | |
| parent | 868dbce755ec92855362d213f47e045a8388361a (diff) | |
| download | linux-017d4012dc05972ce95c2f487725a7a38e24552a.tar.gz linux-017d4012dc05972ce95c2f487725a7a38e24552a.tar.bz2 linux-017d4012dc05972ce95c2f487725a7a38e24552a.zip | |
dmaengine: idxd: fix memory leak in error handling path of idxd_pci_probe
commit 90022b3a6981ec234902be5dbf0f983a12c759fc upstream.
Memory allocated for idxd is not freed if an error occurs during
idxd_pci_probe(). To fix it, free the allocated memory in the reverse
order of allocation before exiting the function in case of an error.
Fixes: bfe1d56091c1 ("dmaengine: idxd: Init and probe for Intel data accelerators")
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-8-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 | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c index 34d4682d91ef..bd3952d90ced 100644 --- a/drivers/dma/idxd/init.c +++ b/drivers/dma/idxd/init.c @@ -585,6 +585,17 @@ static void idxd_read_caps(struct idxd_device *idxd) idxd->hw.iaa_cap.bits = ioread64(idxd->reg_base + IDXD_IAACAP_OFFSET); } +static void idxd_free(struct idxd_device *idxd) +{ + if (!idxd) + return; + + put_device(idxd_confdev(idxd)); + bitmap_free(idxd->opcap_bmap); + ida_free(&idxd_ida, idxd->id); + kfree(idxd); +} + static struct idxd_device *idxd_alloc(struct pci_dev *pdev, struct idxd_driver_data *data) { struct device *dev = &pdev->dev; @@ -857,7 +868,7 @@ static int idxd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) err: pci_iounmap(pdev, idxd->reg_base); err_iomap: - put_device(idxd_confdev(idxd)); + idxd_free(idxd); err_idxd_alloc: pci_disable_device(pdev); return rc; |
