hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/md/dm-verity-fec.c
....@@ -1,12 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (C) 2015 Google, Inc.
34 *
45 * 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.
106 */
117
128 #include "dm-verity-fec.h"
....@@ -73,7 +69,7 @@
7369 *offset = (unsigned)rem;
7470
7571 res = dm_bufio_read(v->fec->bufio, block, buf);
76
- if (unlikely(IS_ERR(res))) {
72
+ if (IS_ERR(res)) {
7773 DMERR("%s: FEC %llu: parity read failed (block %llu): %ld",
7874 v->data_dev->name, (unsigned long long)rsb,
7975 (unsigned long long)block, PTR_ERR(res));
....@@ -162,7 +158,7 @@
162158 dm_bufio_release(buf);
163159
164160 par = fec_read_parity(v, rsb, block_offset, &offset, &buf);
165
- if (unlikely(IS_ERR(par)))
161
+ if (IS_ERR(par))
166162 return PTR_ERR(par);
167163 }
168164 }
....@@ -211,11 +207,14 @@
211207 struct dm_verity_fec_io *fio = fec_io(io);
212208 u64 block, ileaved;
213209 u8 *bbuf, *rs_block;
214
- u8 want_digest[v->digest_size];
210
+ u8 want_digest[HASH_MAX_DIGESTSIZE];
215211 unsigned n, k;
216212
217213 if (neras)
218214 *neras = 0;
215
+
216
+ if (WARN_ON(v->digest_size > sizeof(want_digest)))
217
+ return -EINVAL;
219218
220219 /*
221220 * read each of the rsn data blocks that are part of the RS block, and
....@@ -249,7 +248,7 @@
249248 }
250249
251250 bbuf = dm_bufio_read(bufio, block, &buf);
252
- if (unlikely(IS_ERR(bbuf))) {
251
+ if (IS_ERR(bbuf)) {
253252 DMWARN_LIMIT("%s: FEC %llu: read failed (%llu): %ld",
254253 v->data_dev->name,
255254 (unsigned long long)rsb,