Skip to content

Commit 4958737

Browse files
axiqiagregkh
authored andcommitted
dmaengine: idxd: fix memory leak in error handling path of idxd_setup_engines
commit 817bced 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: 75b9113 ("dmaengine: idxd: fix engine conf_dev lifetime") Cc: [email protected] Signed-off-by: Shuai Xue <[email protected]> Reviewed-by: Dave Jiang <[email protected]> Reviewed-by: Fenghua Yu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 5fcd392 commit 4958737

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
@@ -273,6 +273,7 @@ static int idxd_setup_engines(struct idxd_device *idxd)
273273
rc = dev_set_name(conf_dev, "engine%d.%d", idxd->id, engine->id);
274274
if (rc < 0) {
275275
put_device(conf_dev);
276+
kfree(engine);
276277
goto err;
277278
}
278279

@@ -286,7 +287,10 @@ static int idxd_setup_engines(struct idxd_device *idxd)
286287
engine = idxd->engines[i];
287288
conf_dev = engine_confdev(engine);
288289
put_device(conf_dev);
290+
kfree(engine);
289291
}
292+
kfree(idxd->engines);
293+
290294
return rc;
291295
}
292296

0 commit comments

Comments
 (0)