]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: reset context FD on error
authoryangzz-97 <70520104+yangzz-97@users.noreply.github.com>
Sun, 6 Sep 2020 10:30:48 +0000 (18:30 +0800)
committerKarel Zak <kzak@redhat.com>
Mon, 7 Sep 2020 10:09:36 +0000 (12:09 +0200)
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>
libfdisk/src/context.c

index 327e03b42b214381e69e4a01bb5364030061fad5..206627849c32c6465ad6040d5e3cd6be77593160 100644 (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;
        }