dm: modify DIR handler reference postion

DIR handler is referenced after release, need to be adjusted before
released.

Tracked-On: #3821
Signed-off-by: Gao Junhao <junhao.gao@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
Gao Junhao 2019-10-15 03:26:06 +00:00 committed by ACRN System Integration
parent de157ab96c
commit 477f8331eb
1 changed files with 2 additions and 2 deletions

View File

@ -234,7 +234,6 @@ static int pci_npk_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
else else
break; break;
} }
closedir(dir);
if (!dent) { if (!dent) {
WPRINTF(("Cannot find NPK device\n")); WPRINTF(("Cannot find NPK device\n"));
@ -246,9 +245,10 @@ static int pci_npk_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
dent->d_name); dent->d_name);
if (rc >= PATH_MAX || rc < 0) if (rc >= PATH_MAX || rc < 0)
WPRINTF(("NPK device name is invalid!\n")); WPRINTF(("NPK device name is invalid!\n"));
closedir(dir);
fd = open(name, O_RDONLY); fd = open(name, O_RDONLY);
if (fd == -1) { if (fd == -1) {
WPRINTF(("Cannot open host NPK config\n")); WPRINTF(("Cannot open host NPK config:%s\n", name));
return error; return error;
} }