]> www.infradead.org Git - users/hch/misc.git/commitdiff
pds_core: fix memory leak in pdsc_debugfs_add_qcq()
authorAbdun Nihaal <abdun.nihaal@gmail.com>
Wed, 9 Apr 2025 05:44:48 +0000 (11:14 +0530)
committerJakub Kicinski <kuba@kernel.org>
Sat, 12 Apr 2025 01:33:22 +0000 (18:33 -0700)
The memory allocated for intr_ctrl_regset, which is passed to
debugfs_create_regset32() may not be cleaned up when the driver is
removed. Fix that by using device managed allocation for it.

Fixes: 45d76f492938 ("pds_core: set up device and adminq")
Signed-off-by: Abdun Nihaal <abdun.nihaal@gmail.com>
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Reviewed-by: Shannon Nelson <shannon.nelson@amd.com>
Link: https://patch.msgid.link/20250409054450.48606-1-abdun.nihaal@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/amd/pds_core/debugfs.c

index ac37a4e738ae7d4669f052cc3785bae5715fdf23..04c5e3abd8d706d082c0996b2768db09be70f0ba 100644 (file)
@@ -154,8 +154,9 @@ void pdsc_debugfs_add_qcq(struct pdsc *pdsc, struct pdsc_qcq *qcq)
                debugfs_create_u32("index", 0400, intr_dentry, &intr->index);
                debugfs_create_u32("vector", 0400, intr_dentry, &intr->vector);
 
-               intr_ctrl_regset = kzalloc(sizeof(*intr_ctrl_regset),
-                                          GFP_KERNEL);
+               intr_ctrl_regset = devm_kzalloc(pdsc->dev,
+                                               sizeof(*intr_ctrl_regset),
+                                               GFP_KERNEL);
                if (!intr_ctrl_regset)
                        return;
                intr_ctrl_regset->regs = intr_ctrl_regs;