Skip to content

Commit aa6f4f9

Browse files
axiqiavinodkoul
authored andcommitted
dmaengine: idxd: fix memory leak in error handling path of idxd_setup_groups
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: 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-4-xueshuai@linux.alibaba.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 817bced commit aa6f4f9

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
@@ -326,6 +326,7 @@ static int idxd_setup_groups(struct idxd_device *idxd)
326326
rc = dev_set_name(conf_dev, "group%d.%d", idxd->id, group->id);
327327
if (rc < 0) {
328328
put_device(conf_dev);
329+
kfree(group);
329330
goto err;
330331
}
331332

@@ -350,7 +351,10 @@ static int idxd_setup_groups(struct idxd_device *idxd)
350351
while (--i >= 0) {
351352
group = idxd->groups[i];
352353
put_device(group_confdev(group));
354+
kfree(group);
353355
}
356+
kfree(idxd->groups);
357+
354358
return rc;
355359
}
356360

0 commit comments

Comments
 (0)