.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) International Business Machines Corp., 2000-2004 |
---|
3 | 4 | * Portions Copyright (C) Tino Reichardt, 2012 |
---|
4 | | - * |
---|
5 | | - * This program is free software; you can redistribute it and/or modify |
---|
6 | | - * it under the terms of the GNU General Public License as published by |
---|
7 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
8 | | - * (at your option) any later version. |
---|
9 | | - * |
---|
10 | | - * This program is distributed in the hope that it will be useful, |
---|
11 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
---|
13 | | - * the GNU General Public License for more details. |
---|
14 | | - * |
---|
15 | | - * You should have received a copy of the GNU General Public License |
---|
16 | | - * along with this program; if not, write to the Free Software |
---|
17 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
18 | 5 | */ |
---|
19 | 6 | |
---|
20 | 7 | #include <linux/fs.h> |
---|
.. | .. |
---|
161 | 148 | * 0 - success |
---|
162 | 149 | * -ENOMEM - insufficient memory |
---|
163 | 150 | * -EIO - i/o error |
---|
| 151 | + * -EINVAL - wrong bmap data |
---|
164 | 152 | */ |
---|
165 | 153 | int dbMount(struct inode *ipbmap) |
---|
166 | 154 | { |
---|
.. | .. |
---|
192 | 180 | bmp->db_nfree = le64_to_cpu(dbmp_le->dn_nfree); |
---|
193 | 181 | bmp->db_l2nbperpage = le32_to_cpu(dbmp_le->dn_l2nbperpage); |
---|
194 | 182 | bmp->db_numag = le32_to_cpu(dbmp_le->dn_numag); |
---|
| 183 | + if (!bmp->db_numag) { |
---|
| 184 | + release_metapage(mp); |
---|
| 185 | + kfree(bmp); |
---|
| 186 | + return -EINVAL; |
---|
| 187 | + } |
---|
| 188 | + |
---|
195 | 189 | bmp->db_maxlevel = le32_to_cpu(dbmp_le->dn_maxlevel); |
---|
196 | 190 | bmp->db_maxag = le32_to_cpu(dbmp_le->dn_maxag); |
---|
197 | 191 | bmp->db_agpref = le32_to_cpu(dbmp_le->dn_agpref); |
---|
.. | .. |
---|
391 | 385 | } |
---|
392 | 386 | |
---|
393 | 387 | /* write the last buffer. */ |
---|
394 | | - write_metapage(mp); |
---|
| 388 | + if (mp) |
---|
| 389 | + write_metapage(mp); |
---|
395 | 390 | |
---|
396 | 391 | IREAD_UNLOCK(ipbmap); |
---|
397 | 392 | |
---|
.. | .. |
---|
4040 | 4035 | */ |
---|
4041 | 4036 | #define MAXL0PAGES (1 + LPERCTL) |
---|
4042 | 4037 | #define MAXL1PAGES (1 + LPERCTL * MAXL0PAGES) |
---|
4043 | | -#define MAXL2PAGES (1 + LPERCTL * MAXL1PAGES) |
---|
4044 | 4038 | |
---|
4045 | 4039 | /* |
---|
4046 | 4040 | * convert number of map pages to the zero origin top dmapctl level |
---|