]> www.infradead.org Git - users/hch/misc.git/commitdiff
hisi_acc_vfio_pci: Fix reference leak in hisi_acc_vfio_debug_init
authorMiaoqian Lin <linmq006@gmail.com>
Mon, 1 Sep 2025 08:18:08 +0000 (16:18 +0800)
committerAlex Williamson <alex.williamson@redhat.com>
Fri, 19 Sep 2025 20:39:52 +0000 (14:39 -0600)
The debugfs_lookup() function returns a dentry with an increased reference
count that must be released by calling dput().

Fixes: b398f91779b8 ("hisi_acc_vfio_pci: register debugfs for hisilicon migration driver")
Cc: stable@vger.kernel.org
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Reviewed-by: Longfang Liu <liulongfang@huawei.com>
Link: https://lore.kernel.org/r/20250901081809.2286649-1-linmq006@gmail.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c

index 397f5e4451363954765ed93bd28e49cbbb73c31c..fde33f54e99ec56f59b80373635be502a129c9d9 100644 (file)
@@ -1612,8 +1612,10 @@ static void hisi_acc_vfio_debug_init(struct hisi_acc_vf_core_device *hisi_acc_vd
        }
 
        migf = kzalloc(sizeof(*migf), GFP_KERNEL);
-       if (!migf)
+       if (!migf) {
+               dput(vfio_dev_migration);
                return;
+       }
        hisi_acc_vdev->debug_migf = migf;
 
        vfio_hisi_acc = debugfs_create_dir("hisi_acc", vfio_dev_migration);
@@ -1623,6 +1625,8 @@ static void hisi_acc_vfio_debug_init(struct hisi_acc_vf_core_device *hisi_acc_vd
                                    hisi_acc_vf_migf_read);
        debugfs_create_devm_seqfile(dev, "cmd_state", vfio_hisi_acc,
                                    hisi_acc_vf_debug_cmd);
+
+       dput(vfio_dev_migration);
 }
 
 static void hisi_acc_vf_debugfs_exit(struct hisi_acc_vf_core_device *hisi_acc_vdev)