Skip to content

Commit abe9662

Browse files
committed
Fix coverity defect #1462989
1 parent 20ef77f commit abe9662

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/nvc_mount.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -382,13 +382,13 @@ nvc_driver_mount(struct nvc_context *ctx, const struct nvc_container *cnt, const
382382
if (validate_args(ctx, cnt != NULL && info != NULL) < 0)
383383
return (-1);
384384

385+
if (nsenter(&ctx->err, cnt->mnt_ns, CLONE_NEWNS) < 0)
386+
return (-1);
387+
385388
nmnt = 2 + info->nbins + info->nlibs + info->nlibs32 + info->nipcs + info->ndevs;
386389
mnt = ptr = (const char **)array_new(&ctx->err, nmnt);
387390
if (mnt == NULL)
388-
return (-1);
389-
390-
if (nsenter(&ctx->err, cnt->mnt_ns, CLONE_NEWNS) < 0)
391-
return (-1);
391+
goto fail;
392392

393393
/* Procfs mount */
394394
if ((*ptr++ = mount_procfs(&ctx->err, cnt)) == NULL)
@@ -448,7 +448,7 @@ nvc_driver_mount(struct nvc_context *ctx, const struct nvc_container *cnt, const
448448

449449
fail:
450450
if (rv < 0) {
451-
for (size_t i = 0; i < nmnt; ++i)
451+
for (size_t i = 0; mnt != NULL && i < nmnt; ++i)
452452
unmount(mnt[i]);
453453
assert_func(nsenterat(NULL, ctx->mnt_ns, CLONE_NEWNS));
454454
} else {

0 commit comments

Comments
 (0)