libfdisk: don't use errno after close()
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
fdaba3eb62
commit
199f8cd3b5
|
@ -537,7 +537,7 @@ static void reset_context(struct fdisk_context *cxt)
|
|||
int fdisk_assign_device(struct fdisk_context *cxt,
|
||||
const char *fname, int readonly)
|
||||
{
|
||||
int fd;
|
||||
int fd, rc = 0;
|
||||
|
||||
DBG(CXT, ul_debugobj(cxt, "assigning device %s", fname));
|
||||
assert(cxt);
|
||||
|
@ -598,10 +598,11 @@ int fdisk_assign_device(struct fdisk_context *cxt,
|
|||
fname, readonly ? "READ-ONLY" : "READ-WRITE"));
|
||||
return 0;
|
||||
fail:
|
||||
rc = -errno;
|
||||
if (fd >= 0)
|
||||
close(fd);
|
||||
DBG(CXT, ul_debugobj(cxt, "failed to assign device"));
|
||||
return -errno;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue