Commit 86e3e83b authored by Sami Tolvanen's avatar Sami Tolvanen Committed by Mike Snitzer

dm verity fec: fix bufio leaks

Buffers read through dm_bufio_read() were not released in all code paths.

Fixes: a739ff3f ("dm verity: add support for forward error correction")
Cc: stable@vger.kernel.org # v4.5+
Signed-off-by: default avatarSami Tolvanen <samitolvanen@google.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent 7a0c5c5b
...@@ -146,8 +146,6 @@ static int fec_decode_bufs(struct dm_verity *v, struct dm_verity_fec_io *fio, ...@@ -146,8 +146,6 @@ static int fec_decode_bufs(struct dm_verity *v, struct dm_verity_fec_io *fio,
block = fec_buffer_rs_block(v, fio, n, i); block = fec_buffer_rs_block(v, fio, n, i);
res = fec_decode_rs8(v, fio, block, &par[offset], neras); res = fec_decode_rs8(v, fio, block, &par[offset], neras);
if (res < 0) { if (res < 0) {
dm_bufio_release(buf);
r = res; r = res;
goto error; goto error;
} }
...@@ -172,6 +170,8 @@ static int fec_decode_bufs(struct dm_verity *v, struct dm_verity_fec_io *fio, ...@@ -172,6 +170,8 @@ static int fec_decode_bufs(struct dm_verity *v, struct dm_verity_fec_io *fio,
done: done:
r = corrected; r = corrected;
error: error:
dm_bufio_release(buf);
if (r < 0 && neras) if (r < 0 && neras)
DMERR_LIMIT("%s: FEC %llu: failed to correct: %d", DMERR_LIMIT("%s: FEC %llu: failed to correct: %d",
v->data_dev->name, (unsigned long long)rsb, r); v->data_dev->name, (unsigned long long)rsb, r);
...@@ -269,7 +269,7 @@ static int fec_read_bufs(struct dm_verity *v, struct dm_verity_io *io, ...@@ -269,7 +269,7 @@ static int fec_read_bufs(struct dm_verity *v, struct dm_verity_io *io,
&is_zero) == 0) { &is_zero) == 0) {
/* skip known zero blocks entirely */ /* skip known zero blocks entirely */
if (is_zero) if (is_zero)
continue; goto done;
/* /*
* skip if we have already found the theoretical * skip if we have already found the theoretical
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment