Skip to content

Commit 56e2f09

Browse files
axiqiagregkh
authored andcommitted
dmaengine: idxd: fix memory leak in error handling path of idxd_setup_groups
commit aa6f4f9 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]>
1 parent 4958737 commit 56e2f09

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
@@ -324,6 +324,7 @@ static int idxd_setup_groups(struct idxd_device *idxd)
324324
rc = dev_set_name(conf_dev, "group%d.%d", idxd->id, group->id);
325325
if (rc < 0) {
326326
put_device(conf_dev);
327+
kfree(group);
327328
goto err;
328329
}
329330

@@ -348,7 +349,10 @@ static int idxd_setup_groups(struct idxd_device *idxd)
348349
while (--i >= 0) {
349350
group = idxd->groups[i];
350351
put_device(group_confdev(group));
352+
kfree(group);
351353
}
354+
kfree(idxd->groups);
355+
352356
return rc;
353357
}
354358

0 commit comments

Comments
 (0)