diff options
author | Kinglong Mee <kinglongmee@gmail.com> | 2019-07-11 18:57:13 +0800 |
---|---|---|
committer | Rinku Kothiya <rkothiya@redhat.com> | 2020-03-16 08:01:00 +0000 |
commit | 36e26424f5eabe1332a49c4ffaa3214d38675e29 (patch) | |
tree | 51abeea6ebbcfea176e7f6b7cf435a07ad1f472c | |
parent | 2c5b724c0071ae184dd4bfd441d7346106387ed5 (diff) |
cluster/ec: skip updating ctx->loc again when ec_fix_open/opendir
The ec_manager_open/opendir memsets ctx->loc which causes
memory/inode leak, and ec_fheal uses ctx->loc out of fd->lock
that loc_copy may copy bad data when memset it.
This patch skips updating ctx->loc when it is initilizaed.
With it, ctx->loc is filled once, and never updated.
Change-Id: I3bf5ffce4caf4c1c667f7acaa14b451d37a3550a
fixes: bz#1806843
Signed-off-by: Kinglong Mee <mijinlong@horiscale.com>
-rw-r--r-- | xlators/cluster/ec/src/ec-dir-read.c | 12 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-inode-read.c | 12 |
2 files changed, 14 insertions, 10 deletions
diff --git a/xlators/cluster/ec/src/ec-dir-read.c b/xlators/cluster/ec/src/ec-dir-read.c index c3c6b89dba7..ef6b06fa4dd 100644 --- a/xlators/cluster/ec/src/ec-dir-read.c +++ b/xlators/cluster/ec/src/ec-dir-read.c @@ -123,13 +123,15 @@ ec_manager_opendir(ec_fop_data_t *fop, int32_t state) return EC_STATE_REPORT; } - err = ec_loc_from_loc(fop->xl, &ctx->loc, &fop->loc[0]); - if (err != 0) { - UNLOCK(&fop->fd->lock); + if (!ctx->loc.inode) { + err = ec_loc_from_loc(fop->xl, &ctx->loc, &fop->loc[0]); + if (err != 0) { + UNLOCK(&fop->fd->lock); - fop->error = -err; + fop->error = -err; - return EC_STATE_REPORT; + return EC_STATE_REPORT; + } } UNLOCK(&fop->fd->lock); diff --git a/xlators/cluster/ec/src/ec-inode-read.c b/xlators/cluster/ec/src/ec-inode-read.c index 602c47d3673..503149cf840 100644 --- a/xlators/cluster/ec/src/ec-inode-read.c +++ b/xlators/cluster/ec/src/ec-inode-read.c @@ -771,13 +771,15 @@ ec_manager_open(ec_fop_data_t *fop, int32_t state) return EC_STATE_REPORT; } - err = ec_loc_from_loc(fop->xl, &ctx->loc, &fop->loc[0]); - if (err != 0) { - UNLOCK(&fop->fd->lock); + if (!ctx->loc.inode) { + err = ec_loc_from_loc(fop->xl, &ctx->loc, &fop->loc[0]); + if (err != 0) { + UNLOCK(&fop->fd->lock); - fop->error = -err; + fop->error = -err; - return EC_STATE_REPORT; + return EC_STATE_REPORT; + } } ctx->flags = fop->int32; |