]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid/src/topology/dm: close redundant write file description for pipe before...
authorjiayi0118 <1398871225@qq.com>
Wed, 17 Aug 2022 14:25:27 +0000 (22:25 +0800)
committerjiayi0118 <1398871225@qq.com>
Wed, 17 Aug 2022 14:36:17 +0000 (22:36 +0800)
libblkid/src/topology/dm.c

index b210a805bd6645850d9caa2b287299ee60597aad..1a1cb8ac00c6c6c306038ab3778c480e64ef829f 100644 (file)
@@ -103,6 +103,10 @@ static int probe_dm_tp(blkid_probe pr,
        if (!stream)
                goto nothing;
 
+       if (dmpipe[1] != -1) {
+               close(dmpipe[1]);
+       }
+
        if (fscanf(stream, "%lld %lld striped %d %d ",
                        &offset, &size, &stripes, &stripesize) != 0)
                goto nothing;
@@ -111,7 +115,6 @@ static int probe_dm_tp(blkid_probe pr,
        blkid_topology_set_optimal_io_size(pr, (stripes * stripesize) << 9);
 
        fclose(stream);
-       close(dmpipe[1]);
        return 0;
 
 nothing:
@@ -119,8 +122,6 @@ nothing:
                fclose(stream);
        else if (dmpipe[0] != -1)
                close(dmpipe[0]);
-       if (dmpipe[1] != -1)
-               close(dmpipe[1]);
        return 1;
 }