Skip to content

Commit 817bced

Browse files
axiqiavinodkoul
authored andcommitted
dmaengine: idxd: fix memory leak in error handling path of idxd_setup_engines
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: 75b9113 ("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>
1 parent 3fd2f4b commit 817bced

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/dma/idxd/init.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ static int idxd_setup_engines(struct idxd_device *idxd)
275275
rc = dev_set_name(conf_dev, "engine%d.%d", idxd->id, engine->id);
276276
if (rc < 0) {
277277
put_device(conf_dev);
278+
kfree(engine);
278279
goto err;
279280
}
280281

@@ -288,7 +289,10 @@ static int idxd_setup_engines(struct idxd_device *idxd)
288289
engine = idxd->engines[i];
289290
conf_dev = engine_confdev(engine);
290291
put_device(conf_dev);
292+
kfree(engine);
291293
}
294+
kfree(idxd->engines);
295+
292296
return rc;
293297
}
294298

0 commit comments

Comments
 (0)