| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2015 Google, Inc. |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Author: Sami Tolvanen <samitolvanen@google.com> |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 7 | | - * under the terms of the GNU General Public License as published by the Free |
|---|
| 8 | | - * Software Foundation; either version 2 of the License, or (at your option) |
|---|
| 9 | | - * any later version. |
|---|
| 10 | 6 | */ |
|---|
| 11 | 7 | |
|---|
| 12 | 8 | #include "dm-verity-fec.h" |
|---|
| .. | .. |
|---|
| 73 | 69 | *offset = (unsigned)rem; |
|---|
| 74 | 70 | |
|---|
| 75 | 71 | res = dm_bufio_read(v->fec->bufio, block, buf); |
|---|
| 76 | | - if (unlikely(IS_ERR(res))) { |
|---|
| 72 | + if (IS_ERR(res)) { |
|---|
| 77 | 73 | DMERR("%s: FEC %llu: parity read failed (block %llu): %ld", |
|---|
| 78 | 74 | v->data_dev->name, (unsigned long long)rsb, |
|---|
| 79 | 75 | (unsigned long long)block, PTR_ERR(res)); |
|---|
| .. | .. |
|---|
| 162 | 158 | dm_bufio_release(buf); |
|---|
| 163 | 159 | |
|---|
| 164 | 160 | par = fec_read_parity(v, rsb, block_offset, &offset, &buf); |
|---|
| 165 | | - if (unlikely(IS_ERR(par))) |
|---|
| 161 | + if (IS_ERR(par)) |
|---|
| 166 | 162 | return PTR_ERR(par); |
|---|
| 167 | 163 | } |
|---|
| 168 | 164 | } |
|---|
| .. | .. |
|---|
| 211 | 207 | struct dm_verity_fec_io *fio = fec_io(io); |
|---|
| 212 | 208 | u64 block, ileaved; |
|---|
| 213 | 209 | u8 *bbuf, *rs_block; |
|---|
| 214 | | - u8 want_digest[v->digest_size]; |
|---|
| 210 | + u8 want_digest[HASH_MAX_DIGESTSIZE]; |
|---|
| 215 | 211 | unsigned n, k; |
|---|
| 216 | 212 | |
|---|
| 217 | 213 | if (neras) |
|---|
| 218 | 214 | *neras = 0; |
|---|
| 215 | + |
|---|
| 216 | + if (WARN_ON(v->digest_size > sizeof(want_digest))) |
|---|
| 217 | + return -EINVAL; |
|---|
| 219 | 218 | |
|---|
| 220 | 219 | /* |
|---|
| 221 | 220 | * read each of the rsn data blocks that are part of the RS block, and |
|---|
| .. | .. |
|---|
| 249 | 248 | } |
|---|
| 250 | 249 | |
|---|
| 251 | 250 | bbuf = dm_bufio_read(bufio, block, &buf); |
|---|
| 252 | | - if (unlikely(IS_ERR(bbuf))) { |
|---|
| 251 | + if (IS_ERR(bbuf)) { |
|---|
| 253 | 252 | DMWARN_LIMIT("%s: FEC %llu: read failed (%llu): %ld", |
|---|
| 254 | 253 | v->data_dev->name, |
|---|
| 255 | 254 | (unsigned long long)rsb, |
|---|