Skip to content

Commit 2e29755

Browse files
axiqiavijay-suman
authored andcommitted
dmaengine: idxd: fix memory leak in error handling path of idxd_setup_groups
commit aa6f4f945b10eac57aed46154ae7d6fada7fccc7 upstream. Memory allocated for groups is not freed if an error occurs during idxd_setup_groups(). To fix it, free the allocated memory in the reverse order of allocation before exiting the function in case of an error. Fixes: defe49f ("dmaengine: idxd: fix group 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]> (cherry picked from commit d83e52750d9a1d81913bbfe5e1a9c90acf6b4b4d) Signed-off-by: Vijayendra Suman <[email protected]>
1 parent 0448cdb commit 2e29755

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
@@ -306,6 +306,7 @@ static int idxd_setup_groups(struct idxd_device *idxd)
306306
rc = dev_set_name(conf_dev, "group%d.%d", idxd->id, group->id);
307307
if (rc < 0) {
308308
put_device(conf_dev);
309+
kfree(group);
309310
goto err;
310311
}
311312

@@ -330,7 +331,10 @@ static int idxd_setup_groups(struct idxd_device *idxd)
330331
while (--i >= 0) {
331332
group = idxd->groups[i];
332333
put_device(group_confdev(group));
334+
kfree(group);
333335
}
336+
kfree(idxd->groups);
337+
334338
return rc;
335339
}
336340

0 commit comments

Comments
 (0)