From 48bcd98ec63de179f4072867423288c6c19e9937 Mon Sep 17 00:00:00 2001 From: Gao Junhao Date: Tue, 15 Oct 2019 03:26:06 +0000 Subject: [PATCH] dm: modify DIR handler reference postion DIR handler is referenced after release, need to be adjusted before released. Tracked-On: #4106 Signed-off-by: Gao Junhao Reviewed-by: Yonghua Huang Acked-by: Yu Wang --- devicemodel/hw/pci/npk.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/devicemodel/hw/pci/npk.c b/devicemodel/hw/pci/npk.c index 7dce94630..88aae2d69 100644 --- a/devicemodel/hw/pci/npk.c +++ b/devicemodel/hw/pci/npk.c @@ -234,7 +234,6 @@ static int pci_npk_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts) else break; } - closedir(dir); if (!dent) { WPRINTF(("Cannot find NPK device\n")); @@ -246,9 +245,11 @@ static int pci_npk_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts) dent->d_name); if (rc > PATH_MAX) WPRINTF(("NPK device name too long\n")); + + closedir(dir); fd = open(name, O_RDONLY); if (fd == -1) { - WPRINTF(("Cannot open host NPK config\n")); + WPRINTF(("Cannot open host NPK config:%s\n", name)); return error; }