libfdisk: reset context FD on error

When the query disk fails, reset cxt->dev_fd.

Addresses: https://github.com/karelzak/util-linux/pull/1137
Addresses: https://github.com/karelzak/util-linux/issues/1131
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
yangzz-97 2020-09-06 18:30:48 +08:00 committed by Karel Zak
parent f29a2cfbe1
commit 933f095feb
1 changed files with 1 additions and 0 deletions

View File

@ -636,6 +636,7 @@ static int fdisk_assign_fd(struct fdisk_context *cxt, int fd,
fail:
{
int rc = -errno;
cxt->dev_fd = -1;
DBG(CXT, ul_debugobj(cxt, "failed to assign device [rc=%d]", rc));
return rc;
}