From: jiayi0118 <1398871225@qq.com> Date: Wed, 17 Aug 2022 14:25:27 +0000 (+0800) Subject: libblkid/src/topology/dm: close redundant write file description for pipe before... X-Git-Tag: v2.39-rc1~548^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3f5dd5fa812120764312a2326285e88b2be82c2f;p=thirdparty%2Futil-linux.git libblkid/src/topology/dm: close redundant write file description for pipe before reading data. --- diff --git a/libblkid/src/topology/dm.c b/libblkid/src/topology/dm.c index b210a805bd..1a1cb8ac00 100644 --- a/libblkid/src/topology/dm.c +++ b/libblkid/src/topology/dm.c @@ -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; }